idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
10,000
public static function getDatabase ( ) { $ attribute = 'database' ; if ( ! static :: hasClassAttribute ( $ attribute ) ) { $ database = Database :: getDefault ( ) ; if ( ! $ database ) { $ error = static :: error ( 'connection' , 'database not found' , 'required-for' , 6 ) ; switch ( static :: getClassConfig ( 'error-m...
Retriece linked database or default .
10,001
public function normalize ( SchemaContainer $ schemaContainer ) { $ this -> fixNames ( $ schemaContainer ) ; $ fields = [ ] ; foreach ( $ schemaContainer -> getTypes ( ) as $ type ) { $ fields = array_merge ( $ fields , $ type -> getFields ( ) ) ; } if ( null !== $ querySchema = $ schemaContainer -> getQuerySchema ( ) ...
Validates mapping and fixes missing definitions
10,002
private function mergeResolveConfig ( SchemaContainer $ schemaContainer , Field $ field ) { $ typeName = TypeParser :: getFinalType ( $ field -> getType ( ) ) ; if ( $ schemaContainer -> hasType ( $ typeName ) ) { $ typeConfig = $ schemaContainer -> getType ( $ typeName ) -> getResolveConfig ( ) ; } elseif ( $ schemaCo...
Apply the resolve config of types that are used by query fields
10,003
protected function getAddress ( string $ ip ) : Collection { return $ this -> provider -> geocodeQuery ( GeocodeQuery :: create ( $ ip ) ) ; }
Get the address of an ip
10,004
private function getIp ( ServerRequestInterface $ request ) : string { $ server = $ request -> getServerParams ( ) ; if ( $ this -> ipAttribute !== null ) { return $ request -> getAttribute ( $ this -> ipAttribute ) ; } return isset ( $ server [ 'REMOTE_ADDR' ] ) ? $ server [ 'REMOTE_ADDR' ] : '' ; }
Get the client ip .
10,005
public function addHashPrefixes ( $ prefixes , $ list ) { $ listdir = $ this -> getListStorageDir ( $ list ) ; if ( ! is_dir ( $ listdir ) ) { mkdir ( $ listdir , 0777 , true ) ; } $ new_prefixes = array_map ( 'bin2hex' , $ prefixes ) ; if ( is_file ( $ listdir . $ this -> prefixes_filename ) ) { $ existing_prefixes = ...
Adds one or more hashprefixes
10,006
public function removeHashPrefixesFromList ( $ list ) { $ this -> debugLog ( 'removeHashPrefixesFromList() list ' . $ list ) ; $ listdir = $ this -> getListStorageDir ( $ list ) ; if ( ! $ listdir || strlen ( $ listdir ) < 10 ) { $ this -> warningLog ( 'removeHashPrefixesFromList() invalid list directory for list ' . $...
Remove all prefixes of this list
10,007
public function setUpdaterState ( $ timestamp , $ errorcount ) { $ this -> debugLog ( 'setUpdaterState() called (' . $ timestamp . ', ' . $ errorcount . ')' ) ; file_put_contents ( $ this -> storage_dir . $ this -> nextruntime_filename , $ timestamp ) ; file_put_contents ( $ this -> storage_dir . $ this -> errorcount_f...
Store the nextrun timestamp and errorcount
10,008
public function getNextRunTimestamp ( ) { if ( is_file ( $ this -> storage_dir . $ this -> nextruntime_filename ) ) { return ( int ) file_get_contents ( $ this -> storage_dir . $ this -> nextruntime_filename ) ; } else { return time ( ) ; } }
Retrieve the nextrun timestamp
10,009
public function isListedInCache ( $ lookup_hash ) { $ matched_listnames = null ; $ hex_lookup_hash = bin2hex ( $ lookup_hash ) ; foreach ( $ this -> getLists ( ) as $ listname => $ liststate ) { $ listdir = $ this -> getListStorageDir ( $ listname ) ; if ( ! is_dir ( $ listdir ) ) { $ this -> debugLog ( 'isListedInCach...
Lookup listnames for the given url hash
10,010
private function connect ( ) { $ port = isset ( $ this -> _args [ 'port' ] ) && $ this -> _args [ 'port' ] ? $ this -> _args [ 'port' ] : 3306 ; $ dsn = "mysql:host={$this->_args['host']};port={$port};dbname={$this->_args['dbname']}" ; $ username = $ this -> _args [ 'username' ] ; $ password = $ this -> _args [ 'passwo...
Start PDO connection .
10,011
public function getColumn ( $ sql , $ params = null ) { $ stmt = $ this -> execute ( $ sql , $ params ) ; $ column = [ ] ; while ( $ row = $ stmt -> fetch ( ) ) { $ column [ ] = $ row [ 0 ] ; } return $ column ; }
Get single column elements .
10,012
public function execute ( $ sql , $ params = null ) { $ stmt = $ this -> _pdo -> prepare ( $ sql ) ; if ( is_array ( $ params ) ) { foreach ( $ params as $ token => $ value ) { $ stmt -> bindValue ( $ token , $ value ) ; } } try { $ stmt -> execute ( ) ; } catch ( PDOException $ exception ) { $ this -> _database -> err...
Execute a SQL query on DB with binded values .
10,013
private function getColumnFromName ( $ name ) { foreach ( $ this -> columnConfiguration as $ i => $ col ) { if ( $ col -> getName ( ) == $ name ) { return $ col ; } } throw new DatatableException ( "A requested column was not found in the columnConfiguration." ) ; }
Get the requested column configuration from the name of a column
10,014
private function compileColumnNames ( ) { $ columns = [ ] ; foreach ( $ this -> columnConfiguration as $ column ) { $ columns [ ] = $ column -> getName ( ) ; } return $ columns ; }
Get a list of all the column names for the SELECT query .
10,015
private function sortQuery ( ) { if ( $ this -> queryConfiguration -> hasOrderColumn ( ) ) { $ orderColumns = $ this -> queryConfiguration -> orderColumns ( ) ; foreach ( $ orderColumns as $ order ) { $ this -> query -> orderBy ( $ order -> columnName ( ) , $ order -> isDescending ( ) ? 'desc' : 'asc' ) ; } } }
Will sort the query based on the given datatable query configuration .
10,016
private function limitQuery ( ) { $ this -> query -> skip ( $ this -> queryConfiguration -> start ( ) ) ; $ this -> query -> limit ( $ this -> queryConfiguration -> length ( ) ) ; }
Will limit a query based on the start and length given
10,017
public function securityHistory ( ) { $ history = $ this -> wrappedObject -> security ( ) -> get ( ) ; $ history -> each ( function ( $ item ) { $ item -> security = true ; } ) ; return $ this -> presenter -> decorate ( $ history ) ; }
Get the user s security history .
10,018
public function postRegister ( ) { if ( ! Config :: get ( 'credentials.regallowed' ) ) { return Redirect :: route ( 'account.register' ) ; } $ input = Binput :: only ( [ 'first_name' , 'last_name' , 'email' , 'password' , 'password_confirmation' ] ) ; $ val = UserRepository :: validate ( $ input , array_keys ( $ input ...
Attempt to register a new user .
10,019
private function getNotationAspectsEnum ( $ notation , $ aspects ) { $ enum = $ this -> parseEnumNotation ( $ notation ) ; if ( ! $ enum ) { return $ aspects ; } $ aspects [ 'Default' ] = $ enum [ 0 ] ; $ aspects [ 'Null' ] = in_array ( null , $ enum ) ? 'YES' : 'NO' ; $ tokens = [ ] ; foreach ( $ enum as $ item ) { if...
Get notation aspects for enum .
10,020
private function parseEnumNotation ( $ notation ) { if ( is_string ( $ notation ) ) { $ notation = json_decode ( trim ( $ notation , '<>' ) ) ; if ( json_last_error ( ) ) { return ; } } return $ notation ; }
Parse enum if is inside a string .
10,021
public function update ( array $ input = [ ] ) { DB :: beginTransaction ( ) ; try { LaravelEvent :: fire ( static :: $ name . '.updating' , $ this ) ; $ this -> beforeUpdate ( $ input ) ; $ return = parent :: update ( $ input ) ; $ this -> afterUpdate ( $ input , $ return ) ; LaravelEvent :: fire ( static :: $ name . '...
Update an existing model .
10,022
public function delete ( ) { DB :: beginTransaction ( ) ; try { LaravelEvent :: fire ( static :: $ name . '.deleting' , $ this ) ; $ this -> beforeDelete ( ) ; $ return = parent :: delete ( ) ; $ this -> afterDelete ( $ return ) ; LaravelEvent :: fire ( static :: $ name . '.deleted' , $ this ) ; DB :: commit ( ) ; } ca...
Delete an existing model .
10,023
public static function exists ( $ query ) { static :: applySchema ( ) ; $ table = self :: getTable ( ) ; $ whereArray = [ ] ; $ valuesArray = [ ] ; if ( isset ( $ query [ 'where' ] ) ) { $ whereArray [ ] = $ query [ 'where' ] ; unset ( $ query [ 'where' ] ) ; } $ schema = static :: getSchemaFields ( ) ; foreach ( $ sch...
Alias of ping .
10,024
public function author ( ) { $ user = $ this -> getWrappedObject ( ) -> user ( ) -> withTrashed ( ) -> first ( [ 'first_name' , 'last_name' ] ) ; if ( $ user ) { return $ user -> first_name . ' ' . $ user -> last_name ; } }
Get the author s name .
10,025
protected function checkSpacing ( File $ phpcsFile , $ stackPtr , $ before ) { if ( $ before === true ) { $ stackPtrDiff = - 1 ; $ errorWord = 'prefix' ; $ errorCode = 'Before' ; } else { $ stackPtrDiff = 1 ; $ errorWord = 'follow' ; $ errorCode = 'After' ; } $ tokens = $ phpcsFile -> getTokens ( ) ; $ tokenData = $ to...
Checks spacing at given position .
10,026
private function _processDateTime ( $ dateTime ) { if ( is_numeric ( $ dateTime ) ) { $ timestamp = $ dateTime ; $ dateTime = new \ DateTime ( ) ; $ dateTime -> setTimestamp ( $ timestamp ) ; } elseif ( empty ( $ dateTime ) ) { throw new \ InvalidArgumentException ( 'Date/time is empty' ) ; } elseif ( is_string ( $ dat...
Process mixed format date
10,027
private function _addResultSuffix ( \ DateInterval $ interval , $ result ) { return $ interval -> invert ? self :: $ PREFIX_IN . "\xC2\xA0" . $ result : $ result . "\xC2\xA0" . self :: $ SUFFIX_AGO ; }
Add suffix or Postfix to string .
10,028
public static function getTable ( ) { $ attribute = 'table' ; if ( ! static :: hasClassAttribute ( $ attribute ) ) { $ name = ! isset ( static :: $ table ) ? static :: getClassName ( ) : static :: $ table ; $ conventionName = Functions :: applyConventions ( static :: getClassConfig ( 'table-name-conventions' ) , $ name...
Retrieve table name .
10,029
public function columns ( $ columnName , $ label = null ) { if ( ! is_string ( $ columnName ) ) { throw new \ InvalidArgumentException ( '$columnName must be set' ) ; } if ( $ this -> resetColumns ) { $ this -> columns = [ ] ; $ this -> resetColumns = false ; } if ( is_null ( $ label ) ) { $ label = $ columnName ; } $ ...
Will set the columns for the view
10,030
public function table ( ) { if ( empty ( $ this -> columns ) ) { throw new \ InvalidArgumentException ( "There are no columns defined" ) ; } return $ this -> viewFactory -> make ( $ this -> tableView , [ 'columns' => $ this -> columns , 'showHeaders' => $ this -> printHeaders , 'id' => $ this -> tableId , 'endpoint' =>...
Will render the table
10,031
public function script ( ) { if ( empty ( $ this -> columns ) ) { throw new \ InvalidArgumentException ( "There are no columns defined" ) ; } return $ this -> viewFactory -> make ( $ this -> scriptView , [ 'id' => $ this -> tableId , 'columns' => $ this -> columns , 'options' => $ this -> scriptOptions , 'callbacks' =>...
Will render the javascript for the table
10,032
public function error ( $ type , $ exception ) { switch ( $ type ) { case 'connect' : $ slug = 'Moldable connection error, ' ; $ backtrace = $ this -> _trace ; $ offset = 0 ; break ; case 'execute' : $ slug = 'Moldable query error, ' ; $ backtrace = debug_backtrace ( ) ; $ offset = 2 ; break ; case 'generic' : $ slug =...
Trigger a error .
10,033
public function getContents ( $ row ) { if ( is_callable ( $ this -> options [ 'callable' ] ) ) { if ( is_array ( $ this -> options [ 'callable' ] ) ) { return call_user_func ( $ this -> options [ 'callable' ] , [ $ row ] ) ; } return $ this -> options [ 'callable' ] ( $ row ) ; } $ propertyAccessor = PropertyAccess ::...
gets the content of the row
10,034
public function getActivate ( $ id , $ code ) { if ( ! $ id || ! $ code ) { throw new BadRequestHttpException ( ) ; } try { $ user = Credentials :: getUserProvider ( ) -> findById ( $ id ) ; if ( ! $ user -> attemptActivation ( $ code ) ) { return Redirect :: to ( Config :: get ( 'credentials.home' , '/' ) ) -> with ( ...
Activate an existing user .
10,035
protected function setupBlade ( View $ view ) { $ blade = $ view -> getEngineResolver ( ) -> resolve ( 'blade' ) -> getCompiler ( ) ; $ blade -> directive ( 'auth' , function ( $ expression ) { return "<?php if (\GrahamCampbell\Credentials\Facades\Credentials::check() && \GrahamCampbell\Credentials\Facades\Credentials:...
Setup the blade compiler class .
10,036
protected function registerRevisionRepository ( ) { $ this -> app -> singleton ( 'revisionrepository' , function ( $ app ) { $ model = $ app [ 'config' ] [ 'credentials.revision' ] ; $ revision = new $ model ( ) ; $ validator = $ app [ 'validator' ] ; return new RevisionRepository ( $ revision , $ validator ) ; } ) ; $...
Register the revision repository class .
10,037
protected function registerUserRepository ( ) { $ this -> app -> singleton ( 'userrepository' , function ( $ app ) { $ model = $ app [ 'config' ] [ 'sentry.users.model' ] ; $ user = new $ model ( ) ; $ validator = $ app [ 'validator' ] ; return new UserRepository ( $ user , $ validator ) ; } ) ; $ this -> app -> alias ...
Register the user repository class .
10,038
protected function registerGroupRepository ( ) { $ this -> app -> singleton ( 'grouprepository' , function ( $ app ) { $ model = $ app [ 'config' ] [ 'sentry.groups.model' ] ; $ group = new $ model ( ) ; $ validator = $ app [ 'validator' ] ; return new GroupRepository ( $ group , $ validator ) ; } ) ; $ this -> app -> ...
Register the group repository class .
10,039
protected function registerCredentials ( ) { $ this -> app -> singleton ( 'credentials' , function ( $ app ) { $ sentry = $ app [ 'sentry' ] ; $ decorator = $ app -> make ( PresenterDecorator :: class ) ; return new Credentials ( $ sentry , $ decorator ) ; } ) ; $ this -> app -> alias ( 'credentials' , Credentials :: c...
Register the credentials class .
10,040
protected function registerLoginController ( ) { $ this -> app -> bind ( LoginController :: class , function ( $ app ) { $ throttler = $ app [ 'throttle' ] -> get ( $ app [ 'request' ] , 10 , 10 ) ; return new LoginController ( $ throttler ) ; } ) ; }
Register the login controller class .
10,041
protected function registerRegistrationController ( ) { $ this -> app -> bind ( RegistrationController :: class , function ( $ app ) { $ throttler = $ app [ 'throttle' ] -> get ( $ app [ 'request' ] , 5 , 30 ) ; return new RegistrationController ( $ throttler ) ; } ) ; }
Register the registration controller class .
10,042
protected function registerResetController ( ) { $ this -> app -> bind ( ResetController :: class , function ( $ app ) { $ throttler = $ app [ 'throttle' ] -> get ( $ app [ 'request' ] , 5 , 30 ) ; return new ResetController ( $ throttler ) ; } ) ; }
Register the reset controller class .
10,043
protected function registerActivationController ( ) { $ this -> app -> bind ( ActivationController :: class , function ( $ app ) { $ throttler = $ app [ 'throttle' ] -> get ( $ app [ 'request' ] , 5 , 30 ) ; return new ActivationController ( $ throttler ) ; } ) ; }
Register the resend controller class .
10,044
public function store ( $ values = null ) { static :: applySchema ( ) ; if ( is_array ( $ values ) ) { foreach ( $ values as $ field => $ value ) { $ this -> { $ field } = $ value ; } } $ key = static :: getPrimaryKey ( ) ; if ( $ key && isset ( $ this -> { $ key } ) && $ this -> { $ key } ) { return $ this -> storeUpd...
Auto - store element method .
10,045
public function addProperty ( RelationshipProperty $ property ) { foreach ( $ this -> properties as $ prop ) { if ( $ prop -> getName ( ) === $ property -> getName ( ) ) { $ this -> properties -> removeElement ( $ prop ) ; } } return $ this -> properties -> add ( $ property ) ; }
Adds a relationship property to the collection and avoid duplicated
10,046
public function hasProperty ( $ name ) { if ( null !== $ name ) { $ n = ( string ) $ name ; foreach ( $ this -> properties as $ property ) { if ( $ property -> getName ( ) === $ n ) { return true ; } } } return false ; }
Checks whether or not this relationship has the property with the specified name
10,047
public function getPlural ( $ amount , array $ variants , $ absence = null ) { if ( $ amount || $ absence === null ) { $ result = RUtils :: formatNumber ( $ amount ) . ' ' . $ this -> choosePlural ( $ amount , $ variants ) ; } else { $ result = $ absence ; } return $ result ; }
Get proper case with value
10,048
public function choosePlural ( $ amount , array $ variants ) { if ( sizeof ( $ variants ) < 3 ) { throw new \ InvalidArgumentException ( 'Incorrect values length (must be 3)' ) ; } $ amount = abs ( $ amount ) ; $ mod10 = $ amount % 10 ; $ mod100 = $ amount % 100 ; if ( $ mod10 == 1 && $ mod100 != 11 ) { $ variant = 0 ;...
Choose proper case depending on amount
10,049
private function _sumStringOneOrder ( $ prevResult , $ tmpVal , $ gender , array $ variants ) { if ( $ tmpVal == 0 ) { return array ( $ prevResult , $ tmpVal ) ; } $ words = array ( ) ; $ fiveItems = $ variants [ 2 ] ; $ rest = $ tmpVal % 1000 ; if ( $ rest < 0 ) { throw new \ RangeException ( 'Int overflow' ) ; } $ tm...
Make in - words representation of single order
10,050
public function getInWords ( $ amount , $ gender = RUtils :: MALE ) { if ( $ amount == ( int ) $ amount ) { return $ this -> getInWordsInt ( $ amount , $ gender ) ; } else { return $ this -> getInWordsFloat ( $ amount ) ; } }
Numeral in words
10,051
public function getInWordsInt ( $ amount , $ gender = RUtils :: MALE ) { $ amount = round ( $ amount ) ; return $ this -> sumString ( $ amount , $ gender ) ; }
Integer in words
10,052
private function _getFloatRemainder ( $ value , $ signs = 9 ) { if ( $ value == ( int ) $ value ) { return '0' ; } $ signs = min ( $ signs , sizeof ( self :: $ _FRACTIONS ) ) ; $ value = number_format ( $ value , $ signs , '.' , '' ) ; list ( , $ remainder ) = explode ( '.' , $ value ) ; $ remainder = preg_replace ( '/...
Get remainder of float i . e . 2 . 05 - > 05
10,053
public function actionIndex ( ) { if ( $ this -> searchClass === null ) { $ searchModel = new AssigmentSearch ; } else { $ class = $ this -> searchClass ; $ searchModel = new $ class ; } $ dataProvider = $ searchModel -> search ( \ Yii :: $ app -> request -> getQueryParams ( ) , $ this -> userClassName , $ this -> user...
Lists all Assigment models .
10,054
public function actionView ( $ id ) { $ model = $ this -> findModel ( $ id ) ; $ authManager = Yii :: $ app -> authManager ; $ avaliable = [ ] ; foreach ( $ authManager -> getRoles ( ) as $ role ) { $ avaliable [ $ role -> name ] = $ role -> name ; } $ assigned = [ ] ; foreach ( $ authManager -> getRolesByUser ( $ id )...
Displays a single Assigment model .
10,055
protected function checkContent ( File $ phpcsFile , $ stackPtr , $ before ) { if ( $ before === true ) { $ contentToken = ( $ phpcsFile -> findPrevious ( T_WHITESPACE , ( $ stackPtr - 1 ) , null , true ) + 1 ) ; $ errorWord = 'before' ; } else { $ contentToken = ( $ phpcsFile -> findNext ( T_WHITESPACE , ( $ stackPtr ...
Checks content before concat operator .
10,056
private function transformCollectionData ( $ columnConfiguration , $ searchFunc ) { $ this -> collection -> transform ( function ( $ data ) use ( $ columnConfiguration , $ searchFunc ) { $ entry = [ ] ; foreach ( $ columnConfiguration as $ i => $ col ) { $ func = $ col -> getCallable ( ) ; $ entry [ $ col -> getName ( ...
Transform collection data . Used for searches .
10,057
private function removeEmptyRowsFromCollection ( ) { $ this -> collection = $ this -> collection -> reject ( function ( $ data ) { if ( empty ( $ data ) ) { return true ; } else { return false ; } } ) ; }
Remove the empty rows from the collection
10,058
private function sortCollection ( ) { if ( $ this -> queryConfiguration -> hasOrderColumn ( ) ) { $ order = $ this -> queryConfiguration -> orderColumns ( ) ; $ orderFunc = $ this -> defaultGlobalOrderFunction ; $ this -> collection = $ this -> collection -> sort ( function ( $ first , $ second ) use ( $ order , $ orde...
Will sort the internal collection based on the given query configuration . Most tables only support the ordering by just one column but we will enable sorting on all columns here
10,059
public function createResponse ( ResponseData $ data , QueryConfiguration $ queryConfiguration , array $ columnConfigurations ) { $ responseData = [ 'sEcho' => $ queryConfiguration -> drawCall ( ) , 'iTotalRecords' => $ data -> totalDataCount ( ) , 'iTotalDisplayRecords' => $ data -> filteredDataCount ( ) , 'aaData' =>...
Is responsible to take the generated data and prepare a response for it .
10,060
public static function HexToAscii ( $ hex ) { $ ascii = '' ; if ( strlen ( $ hex ) % 2 == 1 ) $ hex = '0' . $ hex ; for ( $ i = 0 ; $ i < strlen ( $ hex ) ; $ i += 2 ) $ ascii .= chr ( base_convert ( substr ( $ hex , $ i , 2 ) , 16 , 10 ) ) ; return $ ascii ; }
of characters in length
10,061
public function createTable ( $ table , $ schema ) { $ columnsArray = [ ] ; foreach ( $ schema as $ field => $ attributes ) { if ( is_numeric ( $ field ) && is_string ( $ attributes ) ) { $ field = $ attributes ; $ attributes = [ ] ; } $ column = $ this -> columnDefinition ( $ attributes , false ) ; $ columnsArray [ ] ...
Prepare sql code to create a table .
10,062
public function alterTableChange ( $ table , $ field , $ attributes ) { $ column = $ this -> columnDefinition ( $ attributes ) ; $ sql = "ALTER TABLE `{$table}` CHANGE COLUMN `{$field}` `{$field}` {$column}" ; return $ sql ; }
Retrieve sql to alter table definition .
10,063
public function paginate ( ) { $ model = $ this -> model ; if ( property_exists ( $ model , 'order' ) ) { $ paginator = $ model :: orderBy ( $ model :: $ order , $ model :: $ sort ) -> paginate ( $ model :: $ paginate , $ model :: $ index ) ; } else { $ paginator = $ model :: paginate ( $ model :: $ paginate , $ model ...
Get a paginated list of the models .
10,064
protected function isPageInRange ( LengthAwarePaginator $ paginator ) { return $ paginator -> currentPage ( ) <= ceil ( $ paginator -> lastItem ( ) / $ paginator -> perPage ( ) ) ; }
Is this current page in range?
10,065
public function roles ( ) { return $ this -> belongsToMany ( config ( 'laravel-auth.roles.model' , Role :: class ) , $ this -> getPrefix ( ) . config ( 'laravel-auth.role-user.table' , 'role_user' ) ) -> using ( Pivots \ RoleUser :: class ) -> withTimestamps ( ) ; }
User belongs to many roles .
10,066
public function getPermissionsAttribute ( ) { return $ this -> active_roles -> pluck ( 'permissions' ) -> flatten ( ) -> unique ( function ( PermissionContract $ permission ) { return $ permission -> getKey ( ) ; } ) ; }
Get all user permissions .
10,067
public function scopeLastActive ( $ query , $ minutes = null ) { $ date = $ this -> freshTimestamp ( ) -> subMinutes ( $ minutes ? : config ( 'laravel_auth.track-activity.minutes' , 5 ) ) -> toDateTimeString ( ) ; return $ query -> where ( 'last_activity' , '>=' , $ date ) ; }
Scope last active users .
10,068
public function activate ( $ save = true ) { event ( new ActivatingUser ( $ this ) ) ; $ result = $ this -> switchActive ( true , $ save ) ; event ( new ActivatedUser ( $ this ) ) ; return $ result ; }
Activate the model .
10,069
public function deactivate ( $ save = true ) { event ( new DeactivatingUser ( $ this ) ) ; $ result = $ this -> switchActive ( false , $ save ) ; event ( new DeactivatedUser ( $ this ) ) ; return $ result ; }
Deactivate the model .
10,070
public function updateLastActivity ( $ save = true ) { $ this -> forceFill ( [ 'last_activity' => $ this -> freshTimestamp ( ) ] ) ; if ( $ save ) $ this -> save ( ) ; }
Update the user s last activity .
10,071
protected function compareValues ( $ operator , $ value , $ compareValue ) { switch ( $ operator ) { case '==' : return $ value == $ compareValue ; case '===' : return $ value === $ compareValue ; case '!=' : return $ value != $ compareValue ; case '!==' : return $ value !== $ compareValue ; case '>' : return $ value >...
Compares two values with the specified operator .
10,072
public function setItemListElements ( $ itemListElements ) { if ( ! is_array ( $ itemListElements ) ) { throw new \ Exception ( 'The value is expected to be an array' ) ; } foreach ( $ itemListElements as $ itemListElement ) { if ( ! $ itemListElement instanceof Property \ ItemListElement ) { throw new \ Exception ( 'U...
Set item list elements .
10,073
public function check ( ) { if ( $ this -> cache === null ) { $ this -> cache = $ this -> sentry -> check ( ) ; } return $ this -> cache && $ this -> getUser ( ) ; }
Call Sentry s check method or load of cached value .
10,074
public function index ( ) { $ users = UserRepository :: paginate ( ) ; $ links = UserRepository :: links ( ) ; return View :: make ( 'credentials::users.index' , compact ( 'users' , 'links' ) ) ; }
Display a listing of the users .
10,075
public function store ( ) { $ password = Str :: random ( ) ; $ input = array_merge ( Binput :: only ( [ 'first_name' , 'last_name' , 'email' ] ) , [ 'password' => $ password , 'activated' => true , 'activated_at' => new DateTime ( ) , ] ) ; $ rules = UserRepository :: rules ( array_keys ( $ input ) ) ; $ rules [ 'passw...
Store a new user .
10,076
public function show ( $ id ) { $ user = UserRepository :: find ( $ id ) ; $ this -> checkUser ( $ user ) ; if ( $ user -> activated_at ) { $ activated = html_ago ( $ user -> activated_at ) ; } else { if ( Credentials :: hasAccess ( 'admin' ) && Config :: get ( 'credentials.activation' ) ) { $ activated = 'No - <a href...
Show the specified user .
10,077
public function update ( $ id ) { $ input = Binput :: only ( [ 'first_name' , 'last_name' , 'email' ] ) ; $ val = UserRepository :: validate ( $ input , array_keys ( $ input ) ) ; if ( $ val -> fails ( ) ) { return Redirect :: route ( 'users.edit' , [ 'users' => $ id ] ) -> withInput ( ) -> withErrors ( $ val -> errors...
Update an existing user .
10,078
public function suspend ( $ id ) { try { $ throttle = Credentials :: getThrottleProvider ( ) -> findByUserId ( $ id ) ; $ throttle -> suspend ( ) ; } catch ( UserNotFoundException $ e ) { throw new NotFoundHttpException ( 'User Not Found' , $ e ) ; } catch ( UserSuspendedException $ e ) { $ time = $ throttle -> getSusp...
Suspend an existing user .
10,079
public function reset ( $ id ) { $ password = Str :: random ( ) ; $ input = [ 'password' => $ password , ] ; $ rules = [ 'password' => 'required|min:6' , ] ; $ val = UserRepository :: validate ( $ input , $ rules , true ) ; if ( $ val -> fails ( ) ) { return Redirect :: route ( 'users.show' , [ 'users' => $ id ] ) -> w...
Reset the password of an existing user .
10,080
public function resend ( $ id ) { $ user = UserRepository :: find ( $ id ) ; $ this -> checkUser ( $ user ) ; if ( $ user -> activated ) { return Redirect :: route ( 'account.resend' ) -> withInput ( ) -> with ( 'error' , 'That user is already activated.' ) ; } $ code = $ user -> getActivationCode ( ) ; $ mail = [ 'url...
Resend the activation email of an existing user .
10,081
public function destroy ( $ id ) { $ user = UserRepository :: find ( $ id ) ; $ this -> checkUser ( $ user ) ; $ email = $ user -> getLogin ( ) ; try { $ user -> delete ( ) ; } catch ( \ Exception $ e ) { return Redirect :: route ( 'users.show' , [ 'users' => $ id ] ) -> with ( 'error' , 'We were unable to delete the a...
Delete an existing user .
10,082
public function query ( $ sql_string , $ return = self :: FETCH_ASSOC ) { $ query = self :: exec ( $ sql_string ) ; if ( $ query ) { return $ query -> fetch ( $ return ) ; } return 0 ; }
Retunr Array of itens
10,083
public function exec ( $ sql_string ) { $ this -> sql_string = $ sql_string ; $ query = sasql_query ( $ this -> connection , $ this -> sql_string ) ; if ( $ query ) { return new SQLAnywhereQuery ( $ query , $ this -> connection ) ; } else { throw new Exception ( "SQL String Problem :: " . sasql_error ( $ this -> connec...
Exec a query os sql comand
10,084
public function createPermission ( array $ attributes , $ reload = true ) { $ this -> permissions ( ) -> create ( $ attributes ) ; $ this -> loadPermissions ( $ reload ) ; }
Create and attach a permission .
10,085
public function attachPermission ( & $ permission , $ reload = true ) { if ( $ this -> hasPermission ( $ permission ) ) return ; event ( new AttachingPermissionToGroup ( $ this , $ permission ) ) ; $ permission = $ this -> permissions ( ) -> save ( $ permission ) ; event ( new AttachedPermissionToGroup ( $ this , $ per...
Attach the permission to a group .
10,086
public function attachPermissions ( $ permissions , $ reload = true ) { event ( new AttachingPermissionsToGroup ( $ this , $ permissions ) ) ; $ permissions = $ this -> permissions ( ) -> saveMany ( $ permissions ) ; event ( new AttachedPermissionsToGroup ( $ this , $ permissions ) ) ; $ this -> loadPermissions ( $ rel...
Attach a collection of permissions to the group .
10,087
public function detachPermission ( & $ permission , $ reload = true ) { if ( ! $ this -> hasPermission ( $ permission ) ) return ; $ permission = $ this -> getPermissionFromGroup ( $ permission ) ; event ( new DetachingPermissionFromGroup ( $ this , $ permission ) ) ; $ permission -> update ( [ 'group_id' => 0 ] ) ; ev...
Attach the permission from a group .
10,088
public function detachPermissions ( array $ ids , $ reload = true ) { event ( new DetachingPermissionsFromGroup ( $ this , $ ids ) ) ; $ detached = $ this -> permissions ( ) -> whereIn ( 'id' , $ ids ) -> update ( [ 'group_id' => 0 ] ) ; event ( new DetachedPermissionsFromGroup ( $ this , $ ids , $ detached ) ) ; $ thi...
Detach multiple permissions by ids .
10,089
public function detachAllPermissions ( $ reload = true ) { event ( new DetachingAllPermissions ( $ this ) ) ; $ detached = $ this -> permissions ( ) -> update ( [ 'group_id' => 0 ] ) ; event ( new DetachedAllPermissions ( $ this , $ detached ) ) ; $ this -> loadPermissions ( $ reload ) ; return $ detached ; }
Detach all permissions from the group .
10,090
private function getPermissionFromGroup ( $ id ) { if ( $ id instanceof Eloquent ) $ id = $ id -> getKey ( ) ; $ this -> loadPermissions ( ) ; return $ this -> permissions -> filter ( function ( PermissionContract $ permission ) use ( $ id ) { return $ permission -> getKey ( ) == $ id ; } ) -> first ( ) ; }
Get a permission from the group .
10,091
public function find ( $ slug , array $ columns = [ '*' ] ) { $ model = $ this -> model ; return $ model :: where ( 'slug' , '=' , $ slug ) -> first ( $ columns ) ; }
Find an existing model by slug .
10,092
public function run ( ) { $ heading = '' ; if ( isset ( $ this -> heading ) && $ this -> heading != '' ) { Html :: addCssClass ( $ this -> headingOptions , 'panel-heading' ) ; $ heading = Html :: tag ( 'div' , '<h3 class="panel-title">' . $ this -> heading . '</h3>' , $ this -> headingOptions ) ; } $ body = Html :: tag...
Renders the side navigation menu . with the heading and panel containers
10,093
protected function renderMenu ( ) { if ( $ this -> route === null && Yii :: $ app -> controller !== null ) { $ this -> route = Yii :: $ app -> controller -> getRoute ( ) ; } if ( $ this -> params === null ) { $ this -> params = $ _GET ; } $ items = $ this -> normalizeItems ( $ this -> items , $ hasActiveChild ) ; $ opt...
Renders the main menu
10,094
protected function markTopItems ( ) { $ items = [ ] ; foreach ( $ this -> items as $ item ) { if ( empty ( $ item [ 'items' ] ) ) { $ item [ 'top' ] = true ; } $ items [ ] = $ item ; } $ this -> items = $ items ; }
Marks each topmost level item which is not a submenu
10,095
protected function renderItem ( $ item ) { $ this -> validateItems ( $ item ) ; $ template = ArrayHelper :: getValue ( $ item , 'template' , $ this -> linkTemplate ) ; $ url = Url :: to ( ArrayHelper :: getValue ( $ item , 'url' , '#' ) ) ; if ( empty ( $ item [ 'top' ] ) ) { if ( empty ( $ item [ 'items' ] ) ) { $ tem...
Renders the content of a side navigation menu item .
10,096
public function drawCall ( $ drawCall ) { if ( ! is_string ( $ drawCall ) && ! is_numeric ( $ drawCall ) ) { throw new \ InvalidArgumentException ( '$drawCall needs to be a string or numeric' ) ; } $ this -> drawCall = $ drawCall ; return $ this ; }
Will set the drawCall parameter send by the frontend .
10,097
public function searchRegex ( $ searchRegex ) { if ( ! is_bool ( $ searchRegex ) && $ searchRegex !== 'false' && $ searchRegex !== 'true' ) { throw new \ InvalidArgumentException ( '$searchRegex needs to be a boolean' ) ; } $ this -> searchRegex = $ searchRegex ; return $ this ; }
Will indicate if the global search value should be used as a regular expression
10,098
public function columnSearch ( $ columnName , $ searchValue ) { if ( ! is_string ( $ searchValue ) ) { throw new \ InvalidArgumentException ( '$searchValue needs to be a string' ) ; } $ this -> columSearches [ $ columnName ] = new ColumnSearch ( $ columnName , $ searchValue ) ; return $ this ; }
Will add the given search value to the given column which indicates that the frontend wants to search on the given column for the given value
10,099
public function columnOrder ( $ columnName , $ orderDirection ) { if ( ! is_string ( $ orderDirection ) ) { throw new \ InvalidArgumentException ( '$orderDirection "' . $ orderDirection . '" needs to be a string' ) ; } $ isAscOrdering = $ orderDirection === "asc" ? true : false ; $ this -> columnOrders [ ] = new Column...
Will set the ordering of the column to the given direction if possible