idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
9,900
public function getVariable ( $ key ) { $ key = ( string ) $ key ; return $ this -> hasVariable ( $ key ) ? $ this -> currentRequest -> variables -> $ key : null ; }
Get variable from Call Flow
9,901
public function setVariable ( $ key , $ value ) { $ key = ( string ) $ key ; $ this -> currentRequest -> variables -> $ key = $ value ; return true ; }
Set variable in Call Flow
9,902
public function update ( array $ data ) { $ todolist = Basecamp :: todoLists ( $ this -> bucket -> id ) -> update ( $ this -> id , $ data ) ; $ this -> setAttributes ( $ todolist ) ; return $ todolist ; }
Update the todo list .
9,903
public function getAssetFileLastModified ( ) { if ( $ this -> isAssetFilePathUrl ( ) ) { if ( ( $ aHeaders = get_headers ( $ sAssetFilePath = $ this -> getAssetFilePath ( ) , 1 ) ) && strstr ( $ aHeaders [ 0 ] , '200' ) !== false && ! empty ( $ aHeaders [ 'Last-Modified' ] ) && $ oLastModified = new \ DateTime ( $ aHea...
Retrieve asset file last modified timestamp
9,904
public function getAssetFileSize ( ) { if ( $ this -> isAssetFilePathUrl ( ) ) { if ( ( $ aHeaders = get_headers ( $ sAssetFilePath = $ this -> getAssetFilePath ( ) , 1 ) ) && strstr ( $ aHeaders [ 0 ] , '200' ) !== false && ! empty ( $ aHeaders [ 'Content-Length' ] ) && $ iAssetFileSize = $ aHeaders [ 'Content-Length'...
Retrieve asset file size
9,905
public static function assetFileTypeExists ( $ sAssetFileType ) { if ( ! is_string ( $ sAssetFileType ) ) { throw new \ InvalidArgumentException ( 'Asset file type expects string, "' . gettype ( $ sAssetFileType ) . '" given' ) ; } switch ( $ sAssetFileType ) { case self :: ASSET_CSS : case self :: ASSET_LESS : case se...
Check if asset file s type is valid
9,906
public function send ( SendResponseEvent $ event ) { if ( $ this -> response instanceof ConsoleResponse ) { $ templateContent = $ this -> getTemplateContent ( 'console' ) ; $ templateContent = $ this -> injectTemplateContent ( $ templateContent , $ event -> getParams ( ) ) ; $ this -> response -> setContent ( $ templat...
Processes and send response to browser
9,907
public function sendResponse ( $ response ) { while ( ob_get_level ( ) > 0 ) { ob_end_clean ( ) ; } if ( $ response instanceof ConsoleResponse ) { echo $ response -> getContent ( ) ; $ errorLevel = ( int ) $ response -> getErrorLevel ( ) ; exit ( $ errorLevel ) ; } foreach ( $ response -> getHeaders ( ) as $ header ) {...
Send response to the browser
9,908
public function getTemplateContent ( $ type ) { $ type = strtolower ( $ type ) ; $ templateContent = "An error has occured." ; if ( $ this -> getOptions ( ) -> getTemplate ( $ type ) && file_exists ( $ this -> getOptions ( ) -> getTemplate ( $ type ) ) ) { $ templatePath = $ this -> getOptions ( ) -> getTemplate ( $ ty...
Get content of template
9,909
public function injectTemplateContent ( $ content , $ params ) { return str_replace ( array ( '%__ERROR_TYPE__%' , '%__ERROR_REFERENCE__%' , '%__ERROR_MESSAGE__%' , '%__ERROR_FILE__%' , '%__ERROR_LINE__%' ) , array_map ( 'addslashes' , array ( $ params [ 'type' ] , $ params [ 'reference' ] , $ params [ 'message' ] , $ ...
replace placeholders in template with actual values
9,910
public function unregister ( $ name ) { if ( $ this -> exists ( $ name ) ) { $ this -> handlers -> remove ( $ name ) ; } return $ this ; }
Unregister the specified shortcode by given name .
9,911
public function parse ( $ content ) { $ processor = new Processor ( new RegexParser ( ) , $ this -> handlers ) ; return $ processor -> process ( $ content ) ; }
Parse content and replace parts of it using registered handlers
9,912
public function getJSON ( ) { $ o = new \ stdClass ; $ o -> command = ( string ) $ this -> command ; $ o -> command_id = $ this -> command_id ; $ o -> params = ( object ) $ this -> params ; $ o -> variables = ( object ) $ this -> variables ; return json_encode ( $ o ) ; }
get json response
9,913
public function getFlap ( $ name ) { $ flap = new Flap ( $ this -> adapter , $ name ) ; if ( $ this -> defaultViolationHandler !== null ) { $ flap -> setViolationHandler ( $ this -> defaultViolationHandler ) ; } return $ flap ; }
Creates a new Flap and returns it setting default violation handler .
9,914
public function migrationExists ( $ pathToConfiguration ) { if ( ! is_file ( $ pathToConfiguration ) ) { return false ; } $ pathToMigrationsDirectory = $ this -> getPathToMigrations ( $ pathToConfiguration ) ; if ( $ this -> atLeastOneMigrationFileExist ( $ pathToMigrationsDirectory ) ) { return true ; } return false ;...
Check if migrations exist . At least one file for migrations must exist . For example configuration exists but no migration exist yet would result false .
9,915
private function getPathToMigrations ( $ pathToConfiguration ) { $ pathToMigrationsRootDirectory = dirname ( $ pathToConfiguration ) ; $ pathToMigrationsDirectory = $ pathToMigrationsRootDirectory . DIRECTORY_SEPARATOR . 'data' ; if ( strpos ( $ pathToConfiguration , 'project_migrations' ) ) { $ pathToMigrationsDirecto...
Find path to migration directory . Different path returned for a project migrations .
9,916
public function index ( $ page = null , $ status = null ) { $ url = sprintf ( 'buckets/%d/schedules/%d/entries.json' , $ this -> bucket , $ this -> parent ) ; $ entries = $ this -> client -> get ( $ url , [ 'query' => [ 'page' => $ page , ] , ] ) ; return $ this -> indexResponse ( $ entries , ScheduleEntry :: class ) ;...
Index all the schedule entries .
9,917
public function show ( $ id ) { $ entry = $ this -> client -> get ( sprintf ( 'buckets/%d/schedule_entries/%d.json' , $ this -> bucket , $ id ) ) ; return new ScheduleEntry ( $ this -> response ( $ entry ) ) ; }
Get a schedule entry .
9,918
public function store ( array $ data ) { $ entry = $ this -> client -> post ( sprintf ( 'buckets/%d/schedules/%d/entries.json' , $ this -> bucket , $ this -> parent ) , [ 'json' => $ data , ] ) ; return new ScheduleEntry ( $ this -> response ( $ entry ) ) ; }
Store a schedule entry .
9,919
public function update ( $ id , array $ data ) { $ entry = $ this -> client -> put ( sprintf ( 'buckets/%d/schedule_entries/%d.json' , $ this -> bucket , $ id ) , [ 'json' => $ data , ] ) ; return new ScheduleEntry ( $ this -> response ( $ entry ) ) ; }
Update a schedule entry .
9,920
public function index ( $ page = null ) { $ url = sprintf ( 'buckets/%d/chats/%d/integrations.json' , $ this -> bucket , $ this -> parent ) ; $ chatbots = $ this -> client -> get ( $ url , [ 'query' => [ 'page' => $ page , ] , ] ) ; return $ this -> indexResponse ( $ chatbots , Chatbot :: class ) -> map ( function ( $ ...
Index all chatbots .
9,921
public function show ( $ id ) { $ chatbot = $ this -> client -> get ( sprintf ( 'buckets/%d/chats/%d/integrations/%d.json' , $ this -> bucket , $ this -> parent , $ id ) ) ; $ chatbot = new Chatbot ( $ this -> response ( $ chatbot ) ) ; $ chatbot -> inContext ( $ this -> bucket , $ this -> parent ) ; return $ chatbot ;...
Get a chatbot .
9,922
public function store ( array $ data ) { $ chatbot = $ this -> client -> post ( sprintf ( 'buckets/%d/chats/%d/integrations.json' , $ this -> bucket , $ this -> parent ) , [ 'json' => $ data , ] ) ; $ chatbot = new Chatbot ( $ this -> response ( $ chatbot ) ) ; $ chatbot -> inContext ( $ this -> bucket , $ this -> pare...
Create a chatbot .
9,923
public function update ( $ id , array $ data ) { $ chatbot = $ this -> client -> put ( sprintf ( 'buckets/%d/chats/%d/integrations/%d.json' , $ this -> bucket , $ this -> parent , $ id ) , [ 'json' => $ data ] ) ; $ chatbot = new Chatbot ( $ this -> response ( $ chatbot ) ) ; $ chatbot -> inContext ( $ this -> bucket ,...
Update a chatbot .
9,924
public function destroy ( $ id ) { return $ this -> client -> delete ( sprintf ( 'buckets/%d/chats/%d/integrations/%d.json' , $ this -> bucket , $ this -> parent , $ id ) ) ; }
Delete a chatbot .
9,925
public function build ( ) { $ helperSet = new \ Symfony \ Component \ Console \ Helper \ HelperSet ( ) ; $ doctrineApplication = \ Doctrine \ DBAL \ Migrations \ Tools \ Console \ ConsoleRunner :: createApplication ( $ helperSet ) ; $ doctrineApplication -> setAutoExit ( false ) ; $ doctrineApplication -> setCatchExcep...
Return new application for each build . Application has a reference to command which has internal cache . Reusing same application object with same command leads to an errors due to an old configuration . For example first run with a CE migrations second run with PE migrations both runs would take path to CE migrations...
9,926
public function getTemplate ( $ key ) { if ( isset ( $ this -> templates [ $ key ] ) ) { return $ this -> templates [ $ key ] ; } return null ; }
Get template by key
9,927
public function send ( $ url , $ auth = null , array $ headers = [ ] , $ proxy = null , $ raw_response = false ) { $ request = new \ stdClass ; $ request -> id = ( int ) $ this -> id ; $ request -> method = ( string ) $ this -> method ; $ request -> params = ( array ) $ this -> convertParams ( ) ; $ request -> jsonrpc ...
Send the request!
9,928
protected static function getSchemaBuilder ( Connection $ connection ) { $ schemaBuilder = $ connection -> getSchemaBuilder ( ) ; $ schemaBuilder -> blueprintResolver ( function ( $ table , $ callback ) { return new Blueprint ( $ table , $ callback ) ; } ) ; return $ schemaBuilder ; }
Retrieve the schema builder for the database connection . And set a custom blueprint resolver to return an instance of the Culpa Blueprint class .
9,929
protected function updateBlameables ( Model $ model ) { $ user = $ this -> getActiveUser ( ) ; if ( is_null ( $ user ) ) { return ; } if ( $ this -> isBlameable ( $ model , 'updated' ) && ! $ model -> isDirty ( $ this -> getColumn ( $ model , 'updated' ) ) ) { $ this -> setUpdatedBy ( $ model , $ user ) ; } if ( $ mode...
Update the blameable fields .
9,930
public function updateDeleteBlameable ( Model $ model ) { $ user = $ this -> getActiveUser ( ) ; if ( is_null ( $ user ) ) { return ; } if ( $ this -> isBlameable ( $ model , 'deleted' ) && ! $ model -> isDirty ( $ this -> getColumn ( $ model , 'deleted' ) ) ) { $ this -> setDeletedBy ( $ model , $ user ) ; $ model -> ...
Update the deletedBy blameable field .
9,931
protected function getActiveUser ( ) { if ( ! Config :: has ( 'culpa.users.active_user' ) ) { return Auth :: check ( ) ? Auth :: user ( ) : null ; } $ fn = Config :: get ( 'culpa.users.active_user' ) ; if ( ! is_callable ( $ fn ) ) { throw new \ Exception ( 'culpa.users.active_user should be a closure' ) ; } return $ f...
Get the active user .
9,932
protected function setCreatedBy ( Model $ model , $ user ) { $ model -> { $ this -> getColumn ( $ model , 'created' ) } = $ user -> id ; if ( $ model instanceof CreatorAware ) { $ model -> setRelation ( 'creator' , $ user ) ; } return $ model ; }
Set the created - by field of the model .
9,933
protected function setUpdatedBy ( Model $ model , $ user ) { $ model -> { $ this -> getColumn ( $ model , 'updated' ) } = $ user -> id ; if ( $ model instanceof UpdaterAware ) { $ model -> setRelation ( 'updater' , $ user ) ; } return $ model ; }
Set the updated - by field of the model .
9,934
protected function setDeletedBy ( Model $ model , $ user ) { $ model -> { $ this -> getColumn ( $ model , 'deleted' ) } = $ user -> id ; if ( $ model instanceof EraserAware ) { $ model -> setRelation ( 'eraser' , $ user ) ; } return $ model ; }
Set the deleted - by field of the model .
9,935
protected static function extractBlamableFields ( array $ blameableValue ) { $ fields = array ( ) ; $ checkedFields = array ( 'created' , 'updated' , 'deleted' ) ; foreach ( $ checkedFields as $ possibleField ) { if ( array_key_exists ( $ possibleField , $ blameableValue ) ) { $ fields [ $ possibleField ] = $ blameable...
Internal method that matches the extracted blamable property values with eloquent fields
9,936
protected function getBlameableFields ( Model $ model ) { if ( isset ( $ this -> fields ) ) { return $ this -> fields ; } $ this -> fields = self :: findBlameableFields ( $ model ) ; return $ this -> fields ; }
Get the blameable fields .
9,937
public function gatherDebugBarDetails ( array $ debugBarSelectors , DocumentElement $ page ) { $ details = '' ; foreach ( $ debugBarSelectors as $ name => $ selector ) { $ details .= ' [' . strtoupper ( $ name ) . '] ' ; if ( $ detailText = $ page -> find ( 'css' , $ selector ) ) { $ details .= $ detailText -> getText...
Override if gathering details is complex .
9,938
public function index ( $ page = null ) { $ url = sprintf ( 'buckets/%d/categories.json' , $ this -> bucket ) ; $ messageTypes = $ this -> client -> get ( $ url , [ 'query' => [ 'page' => $ page , ] , ] ) ; return $ this -> indexResponse ( $ messageTypes , MessageType :: class ) ; }
Index all message types .
9,939
public function show ( $ id ) { $ messageType = $ this -> client -> get ( sprintf ( 'buckets/%d/categories/%d.json' , $ this -> bucket , $ id ) ) ; return new MessageType ( $ this -> response ( $ messageType ) ) ; }
Get a message type .
9,940
public function store ( $ data ) { $ message = $ this -> client -> post ( sprintf ( 'buckets/%d/categories.json' , $ this -> bucket ) , [ 'json' => $ data , ] ) ; return new MessageType ( $ this -> response ( $ message ) ) ; }
Store a message type .
9,941
public function index ( $ page = null ) { $ url = sprintf ( 'buckets/%d/client/approvals.json' , $ this -> bucket ) ; $ approvals = $ this -> client -> get ( $ url , [ 'query' => [ 'page' => $ page , ] , ] ) ; return $ this -> indexResponse ( $ approvals , ClientApproval :: class ) ; }
Index all approvals .
9,942
public function show ( $ id ) { $ approval = $ this -> client -> get ( sprintf ( 'buckets/%d/client/approvals/%d.json' , $ this -> bucket , $ id ) ) ; return new ClientApproval ( $ this -> response ( $ approval ) ) ; }
Get a client approval .
9,943
public function creator ( ) { if ( ! method_exists ( $ this , 'getFields' ) ) { throw new BadMethodCallException ( 'You are missing the Blameable Trait' ) ; } $ fields = $ this -> getFields ( ) ; $ model = Config :: get ( 'culpa.users.classname' , 'App\User' ) ; return $ this -> belongsTo ( $ model , $ fields [ 'create...
Get the user that created the model .
9,944
public static function cache ( Repository $ cache = null ) { if ( ! $ cache ) { $ filestore = new FileStore ( new Filesystem ( ) , storage_path ( ) ) ; $ cache = new Repository ( $ filestore ) ; } return new CacheMiddleware ( new PrivateCacheStrategy ( new LaravelCacheStorage ( $ cache ) ) ) ; }
Cache middleware .
9,945
public static function setBaseHeaders ( $ token , $ userAgent ) { return Middleware :: mapRequest ( function ( Request $ request ) use ( $ token , $ userAgent ) { return $ request -> withHeader ( 'Accept' , 'application/json' ) -> withHeader ( 'Authorization' , 'Bearer ' . $ token ) -> withHeader ( 'User-Agent' , $ use...
Set the base request headers .
9,946
public static function retry ( & $ api , $ config ) { $ retryRequest = function ( $ retries , $ request , $ response , $ error ) use ( $ api , $ config ) { if ( $ response and $ response -> getStatusCode ( ) == 401 ) { return self :: refreshToken ( $ api , $ config , $ retries ) ; } return false ; } ; return Middleware...
Retry middleware .
9,947
protected static function refreshToken ( & $ api , $ config , $ retries = 0 ) { if ( $ retries >= 3 ) { return false ; } $ response = ( new Guzzle ) -> post ( Client :: AUTH_TOKEN , [ 'form_params' => [ 'type' => 'refresh' , 'refresh_token' => $ api [ 'refresh_token' ] , 'client_id' => $ config [ 'services.37signals.cl...
Refresh the user token .
9,948
protected static function getClassName ( ) { $ attribute = 'class-name' ; if ( ! static :: hasClassAttribute ( $ attribute ) ) { $ class = static :: getClass ( ) ; $ point = strrpos ( $ class , '\\' ) ; $ className = $ point === false ? $ class : substr ( $ class , $ point + 1 ) ; static :: setClassAttribute ( $ attrib...
Retrieve static class name .
9,949
public static function getClassConfigInherit ( ) { $ attribute = 'class-config-inherit' ; if ( ! static :: hasClassAttribute ( $ attribute ) ) { $ class = static :: getClass ( ) ; $ stack = [ ] ; $ inherit = [ ] ; while ( $ class ) { $ stack [ ] = $ class :: getClassConfigArray ( ) ; $ class = get_parent_class ( $ clas...
Get configuration array inherited .
9,950
protected static function getClassMethodsByPrefix ( $ prefix = null ) { $ attribute = 'MethodsByPrefix:' . $ prefix ; if ( ! static :: hasClassAttribute ( $ attribute ) ) { $ class = static :: getClass ( ) ; $ allMethods = get_class_methods ( $ class ) ; $ methods = [ ] ; if ( count ( $ allMethods ) > 0 ) { foreach ( $...
Get methods names by prefix .
9,951
public function processComment ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ commentText = $ tokens [ $ stackPtr ] [ 'content' ] ; if ( substr ( $ commentText , 0 , 2 ) !== '/*' || substr ( $ commentText , - 2 ) !== '*/' ) { return ; } if ( $ this -> isTypeComment ( $ commentText ) ===...
Processes comment .
9,952
public function processDocBlock ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ commentStart = $ stackPtr ; $ commentEnd = $ tokens [ $ stackPtr ] [ 'comment_closer' ] ; if ( $ tokens [ $ commentEnd ] [ 'line' ] !== $ tokens [ $ commentStart ] [ 'line' ] ) { return ; } $ commentTags = $ ...
Processes DocBlock .
9,953
public function processVariableAssociation ( File $ phpcsFile , $ stackPtr , TypeCommentStructure $ structure ) { if ( $ structure -> variableName === null || $ structure -> isVariable ( $ structure -> variableName ) === false ) { return ; } $ this -> processVariableBeforeDocBlock ( $ phpcsFile , $ stackPtr , $ structu...
Processes variable around DocBlock .
9,954
protected function isTypeComment ( $ commentText ) { return strpos ( $ commentText , self :: TYPE_TAG ) !== false || strpos ( $ commentText , '@type' ) !== false ; }
Checks if comment is type comment .
9,955
public function findFirstOnLine ( File $ phpcsFile , $ start ) { $ tokens = $ phpcsFile -> getTokens ( ) ; for ( $ i = $ start ; $ i >= 0 ; $ i -- ) { if ( $ tokens [ $ i ] [ 'line' ] === $ tokens [ $ start ] [ 'line' ] ) { continue ; } return ( $ i + 1 ) ; } return false ; }
Finds first token on a line .
9,956
public function findLastOnLine ( File $ phpcsFile , $ start ) { $ tokens = $ phpcsFile -> getTokens ( ) ; for ( $ i = $ start ; $ i <= $ phpcsFile -> numTokens ; $ i ++ ) { if ( $ tokens [ $ i ] [ 'line' ] === $ tokens [ $ start ] [ 'line' ] ) { continue ; } return ( $ i - 1 ) ; } return false ; }
Finds last token on a line .
9,957
public function lookup ( $ url ) { $ result = array ( ) ; $ canon_url = GoogleSafeBrowsing_Lookup_URL :: googleCanonicalize ( $ url ) ; if ( is_null ( $ canon_url ) ) { $ this -> debugLog ( 'lookup(' . $ url . '): cannot canonicalize url, skipping' ) ; return $ result ; } $ lookup_urls = GoogleSafeBrowsing_Lookup_URL :...
Lookup an url
9,958
public function setDownMode ( ) { $ file = $ this -> maintenanceFilePath ( ) ; if ( ! touch ( $ file ) ) { $ message = sprintf ( 'Something went wrong on trying to create maintenance file %s.' , $ file ) ; throw new Exceptions \ FileException ( $ message ) ; } return true ; }
Put the application in down mode .
9,959
public function setUpMode ( ) { $ file = $ this -> maintenanceFilePath ( ) ; if ( file_exists ( $ file ) && ! unlink ( $ file ) ) { $ message = sprintf ( 'Something went wrong on trying to remove maintenance file %s.' , $ file ) ; throw new Exceptions \ FileException ( $ message ) ; } return true ; }
Put application in up mode .
9,960
public function findOrFail ( int $ id ) { $ response = $ this -> model -> with ( $ this -> with ) -> findOrFail ( $ id ) ; $ this -> with = [ ] ; return $ response ; }
Get single row or throw a 404
9,961
public function findWhereOrFail ( int $ id , array $ parameters ) { $ response = $ this -> model -> with ( $ this -> with ) -> where ( $ parameters ) -> findOrFail ( $ id ) ; $ this -> with = [ ] ; return $ response ; }
Get a single row matching parameters or throw a 404
9,962
public function detach ( $ model , string $ relation , Model $ value ) { if ( ! $ model instanceof Model ) { $ model = $ this -> find ( $ model ) ; } $ model -> $ relation ( ) -> detach ( $ value ) ; }
Detach a model
9,963
public function addColumn ( $ acronym , $ type = null , array $ options = [ ] ) { if ( in_array ( $ acronym , $ this -> reservedColumnAcronyms ) ) { throw new ReservedColumnAcronymException ( $ acronym ) ; } if ( $ type === null ) { $ type = Column :: class ; } $ column = new $ type ( $ acronym , $ options ) ; if ( ! $...
adds a new column
9,964
public function loadData ( ) { if ( ! is_callable ( $ this -> options [ 'data_loader' ] ) && ! is_array ( $ this -> options [ 'data_loader' ] ) ) { throw new DataLoaderNotAvailableException ( ) ; } if ( $ this -> loaded ) { return ; } $ currentPage = 1 ; $ limit = - 1 ; if ( $ this -> hasExtension ( PaginationExtension...
loads the data
9,965
public function buildGraph ( array $ userSchema ) { $ graphSchema = new GraphSchema ( ) ; foreach ( $ userSchema [ 'nodes' ] as $ id => $ nodeInfo ) { $ node = $ this -> buildNode ( $ id , $ nodeInfo ) ; $ graphSchema -> addNode ( $ node ) ; } if ( ! isset ( $ userSchema [ 'relationships' ] ) ) { $ userSchema [ 'relati...
Build a graph definition based on the user parsed schema
9,966
public function buildRelationship ( array $ relInfo ) { $ relationship = new Relationship ( $ relInfo [ 'start' ] , $ relInfo [ 'end' ] , $ relInfo [ 'type' ] ) ; $ relationship -> setCardinality ( $ relInfo [ 'mode' ] ) ; if ( isset ( $ relInfo [ 'properties' ] ) ) { foreach ( $ relInfo [ 'properties' ] as $ name => $...
Builds the relationship object based on user schema
9,967
public function users ( ) { return $ this -> belongsToMany ( config ( 'laravel-auth.users.model' , User :: class ) , $ this -> getPrefix ( ) . config ( 'laravel-auth.role-user.table' , 'permission_role' ) ) -> using ( Pivots \ RoleUser :: class ) -> withTimestamps ( ) ; }
Role belongs to many users .
9,968
public function permissions ( ) { return $ this -> belongsToMany ( config ( 'laravel-auth.permissions.model' , Permission :: class ) , $ this -> getPrefix ( ) . config ( 'laravel-auth.permission-role.table' , 'permission_role' ) ) -> using ( Pivots \ PermissionRole :: class ) -> withTimestamps ( ) ; }
Role belongs to many permissions .
9,969
public function detachUser ( $ user , $ reload = true ) { event ( new DetachingUserFromRole ( $ this , $ user ) ) ; $ results = $ this -> users ( ) -> detach ( $ user ) ; event ( new DetachedUserFromRole ( $ this , $ user , $ results ) ) ; $ this -> loadUsers ( $ reload ) ; return $ results ; }
Detach a user from a role .
9,970
public function detachAllUsers ( $ reload = true ) { event ( new DetachingAllUsersFromRole ( $ this ) ) ; $ results = $ this -> users ( ) -> detach ( ) ; event ( new DetachedAllUsersFromRole ( $ this , $ results ) ) ; $ this -> loadUsers ( $ reload ) ; return $ results ; }
Detach all users from a role .
9,971
public function detachPermission ( $ permission , $ reload = true ) { if ( ! $ this -> hasPermission ( $ permission ) ) return 0 ; event ( new DetachingPermissionFromRole ( $ this , $ permission ) ) ; $ results = $ this -> permissions ( ) -> detach ( $ permission ) ; event ( new DetachedPermissionFromRole ( $ this , $ ...
Detach a permission from a role .
9,972
public function detachAllPermissions ( $ reload = true ) { if ( $ this -> permissions -> isEmpty ( ) ) return 0 ; event ( new DetachingAllPermissionsFromRole ( $ this ) ) ; $ results = $ this -> permissions ( ) -> detach ( ) ; event ( new DetachedAllPermissionsFromRole ( $ this , $ results ) ) ; $ this -> loadPermissio...
Detach all permissions from a role .
9,973
public function can ( $ slug ) { if ( ! $ this -> isActive ( ) ) return false ; return $ this -> permissions -> filter ( function ( PermissionContract $ permission ) use ( $ slug ) { return $ permission -> hasSlug ( $ slug ) ; } ) -> first ( ) !== null ; }
Check if role is associated with a permission by slug .
9,974
public function canAny ( $ permissions , & $ failed = null ) { $ permissions = is_array ( $ permissions ) ? collect ( $ permissions ) : $ permissions ; $ failed = $ permissions -> reject ( function ( $ permission ) { return $ this -> can ( $ permission ) ; } ) -> values ( ) ; return $ permissions -> count ( ) !== $ fai...
Check if a role is associated with any of given permissions .
9,975
public function canAll ( $ permissions , & $ failed = null ) { $ this -> canAny ( $ permissions , $ failed ) ; return $ failed -> isEmpty ( ) ; }
Check if role is associated with all given permissions .
9,976
public function getNotationType ( $ notation , & $ params = null , & $ errors = null , $ namespace = null ) { $ type = gettype ( $ notation ) ; $ params = null ; switch ( $ type ) { case 'string' : return $ this -> getNotationTypeString ( $ notation , $ params , $ errors , $ namespace ) ; case 'array' : return $ this -...
Get type of a notation .
9,977
public function getActivatedAtAccessor ( $ value ) { if ( $ value ) { return new Carbon ( $ value ) ; } if ( $ this -> getAttribute ( 'activated' ) ) { return $ this -> getAttribute ( 'created_at' ) ; } return false ; }
Activated at accessor .
9,978
public function hasAccess ( $ permissions , $ all = true ) { $ key = sha1 ( json_encode ( $ permissions ) . json_encode ( $ all ) ) ; if ( ! array_key_exists ( $ key , $ this -> access ) ) { $ this -> access [ $ key ] = parent :: hasAccess ( $ permissions , $ all ) ; } return $ this -> access [ $ key ] ; }
Check a user s access .
9,979
public function getCurrentPage ( ) { $ page = $ this -> getRequest ( ) -> query -> getInt ( $ this -> getActionQueryParameter ( static :: QUERY_PARAMETER_PAGE ) , 1 ) ; if ( $ page < 1 ) { $ page = 1 ; } return $ page ; }
returns current page number .
9,980
public function make ( Provider $ provider ) { $ composer = new ColumnComposer ( $ provider , $ this -> versionEngine , $ this -> viewFactory , $ this -> configRepository ) ; return $ composer ; }
Will create a new DataComposer with the given provider as implementation .
9,981
public static function applyConventions ( $ convention , $ string ) { switch ( $ convention ) { case 'camel-case' : return Stringy :: create ( $ string ) -> camelize ( ) ; case 'upper-camel-case' : return Stringy :: create ( $ string ) -> upperCamelize ( ) ; case 'underscore' : return Stringy :: create ( $ string ) -> ...
Apply names conventions as camelCase or snake_case .
9,982
public function build ( ) { $ this -> checkName ( ) ; $ this -> checkCallable ( ) ; $ this -> checkOrderable ( ) ; $ this -> checkSearchable ( ) ; return new ColumnConfiguration ( $ this -> name , $ this -> callable , $ this -> searchable , $ this -> orderable ) ; }
Will create the final ColumnConfiguration
9,983
private function checkCallable ( ) { if ( is_null ( $ this -> callable ) || ! is_callable ( $ this -> callable ) ) { $ this -> callable = function ( $ data ) { $ name = $ this -> name ; if ( is_array ( $ data ) && array_key_exists ( $ name , $ data ) ) { return $ data [ $ name ] ; } if ( is_object ( $ data ) && propert...
Will check if the callable is set and is executable if not a sensible default will be set .
9,984
public function insert ( $ model , $ values , $ map = null ) { if ( is_string ( $ values ) ) { $ values = [ $ values => $ map , ] ; $ map = null ; } $ this -> adapt ( $ model , $ this -> profile ( $ values ) ) ; $ fieldsArray = [ ] ; $ tokensArray = [ ] ; $ valuesArray = [ ] ; foreach ( $ values as $ field => $ value )...
Insert record for specific model with values .
9,985
public static function getDefault ( ) { if ( static :: $ _default != null ) { return static :: $ _default ; } if ( Context :: checkLaravel ( ) ) { static :: $ _default = new self ( [ 'socket' => 'Laravel' ] ) ; return static :: $ _default ; } if ( Context :: checkContainer ( ) ) { return Context :: getContainerDatabase...
Retrieve default SchemaDB connection .
9,986
protected function initSchemaFields ( ) { $ schema = static :: getSchemaFields ( ) ; $ parser = static :: getDatabase ( ) -> getParser ( ) ; foreach ( $ schema as $ field ) { $ this -> { $ field } = $ parser -> getNotationValue ( $ this -> { $ field } ) ; } }
Initialize all fields in class .
9,987
public function fillSchemaFields ( $ values , $ map = null , $ prefix = null ) { if ( is_array ( $ map ) ) { foreach ( $ map as $ alias => $ field ) { if ( isset ( $ values [ $ alias ] ) ) { $ values [ $ field ] = $ values [ $ alias ] ; } } } foreach ( static :: getSchema ( ) as $ field => $ aspects ) { if ( isset ( $ ...
Fill value inside model fields .
9,988
public function getPrimaryKeyValue ( ) { $ key = static :: getPrimaryKey ( ) ; return $ key && isset ( $ this -> { $ key } ) ? $ this -> { $ key } : null ; }
Get primary key value .
9,989
protected static function getStaticFields ( ) { $ attribute = 'StaticFields' ; if ( ! static :: hasClassAttribute ( $ attribute ) ) { $ class = static :: getClass ( ) ; $ reflection = new \ ReflectionClass ( $ class ) ; $ fields = array_keys ( $ reflection -> getStaticProperties ( ) ) ; static :: setClassAttribute ( $ ...
Get all static fields .
9,990
public function createTable ( $ identifier , $ options = [ ] ) { return new Table ( $ identifier , $ options , $ this -> eventDispatcher , $ this -> requestStack , $ this -> templating , $ this -> formatterManager , $ this -> extensions ) ; }
returns a new table object
9,991
public function parse ( Request $ request , array $ columnConfiguration ) { $ query = $ request -> query ; $ builder = QueryConfigurationBuilder :: create ( ) ; $ this -> getDrawCall ( $ query , $ builder ) ; $ this -> getStart ( $ query , $ builder ) ; $ this -> getLength ( $ query , $ builder ) ; $ this -> getSearch ...
Method that should parse the request and return a DTQueryConfiguration
9,992
public static function raw ( $ sql , $ params = null ) { $ results = static :: getDatabase ( ) -> getResults ( $ sql , $ params ) ; return $ results ; }
Execute a raw query on database .
9,993
public function dataLoader ( $ page , $ limit ) { if ( $ limit > 0 ) { $ this -> getQueryBuilder ( ) -> setMaxResults ( $ limit ) ; $ this -> getQueryBuilder ( ) -> setFirstResult ( ( $ page - 1 ) * $ limit ) ; } $ paginator = new Paginator ( $ this -> getQueryBuilder ( ) ) ; $ tableData = new SimpleTableData ( ) ; $ t...
Doctrine table data loader
9,994
public function addNodeLabel ( $ alias = null , $ label ) { if ( null === $ alias ) { $ alias = str_replace ( '.' , '' , 'n' . microtime ( true ) . rand ( 0 , 100000000000 ) ) ; } return $ alias . ':' . $ label . ' ' ; }
Add the node alias and the node label
9,995
public function addNodeProperty ( $ key , $ value ) { if ( is_string ( $ value ) ) { $ value = '"' . htmlentities ( $ value , ENT_QUOTES , 'UTF-8' ) . '"' ; } elseif ( is_int ( $ value ) ) { $ value = 'toInt(' . $ value . ')' ; } return $ key . ':' . $ value ; }
Add a node property key = > value should be used between the openNodePropertiesBracket and closeNodePropertiesBracket methods
9,996
public function addRelationship ( $ start , $ end , $ type , array $ properties = array ( ) ) { $ sa = 'r' . sha1 ( $ start . microtime ( ) ) ; $ es = 'r' . sha1 ( $ end . microtime ( ) ) ; $ q = 'MERGE (' . $ sa . ' { neogen_id: "' . $ start . '" }) ' ; $ q .= 'MERGE (' . $ es . ' { neogen_id: "' . $ end . '" }) ' ; i...
Add a relationship path First it try to merge nodes id s are taken from the already node generated ids
9,997
public function setProvider ( $ provider , array $ arguments = array ( ) ) { if ( null === $ provider || '' === $ provider ) { throw new \ InvalidArgumentException ( 'A property faker provider name can not be empty' ) ; } $ this -> provider = $ provider ; if ( ! empty ( $ arguments ) ) { $ this -> arguments = $ argumen...
Sets the property faker provider to use
9,998
protected function getChildrenRecursive ( $ name , & $ result ) { if ( isset ( $ this -> _children [ $ name ] ) ) { foreach ( $ this -> _children [ $ name ] as $ child ) { $ result [ $ child ] = true ; $ this -> getChildrenRecursive ( $ child , $ result ) ; } } }
Recursively finds all children and grand children of the specified item .
9,999
public static function applySchema ( ) { $ attribute = 'apply-schema' ; if ( static :: hasClassAttribute ( $ attribute ) ) { return true ; } $ database = static :: getDatabase ( ) ; $ schema = static :: getSchema ( ) ; if ( ! $ schema ) { static :: error ( 'class' , 'empty schema not allowed' ) ; } $ table = static :: ...
Apply schema model related .