idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
19,000
public function setAmazonOrderId ( $ value ) { if ( ! $ this -> _isNumericArray ( $ value ) ) { $ value = array ( $ value ) ; } $ this -> _fields [ 'AmazonOrderId' ] [ 'FieldValue' ] = $ value ; return $ this ; }
Set the value of the AmazonOrderId property .
19,001
public function url ( $ path , $ slashes = false ) { $ path = ( $ slashes !== false ) ? explode ( '/' , $ path ) : array ( $ path ) ; foreach ( $ path as $ key => $ value ) { $ path [ $ key ] = URLify :: filter ( $ value ) ; } return implode ( '/' , $ path ) ; }
Slugifies a folder path suitable for urls .
19,002
public function title ( $ string ) { $ string = explode ( ' ' , $ string ) ; foreach ( $ string as $ key => $ value ) { if ( ! empty ( $ value ) && mb_strtoupper ( $ value ) == $ value ) { $ string [ $ key ] = mb_strtolower ( $ value ) ; } } return TextFormatter :: titleCase ( implode ( ' ' , $ string ) ) ; }
Properly formats a title string .
19,003
public function config ( $ key = null ) { $ args = func_get_args ( ) ; if ( is_null ( $ this -> config ) ) { $ file = $ this -> folder . 'config.yml' ; $ this -> config = ( is_file ( $ file ) ) ? ( array ) Yaml :: parse ( file_get_contents ( $ file ) ) : array ( ) ; $ current = true ; foreach ( array ( 'blog' => array ...
Retrieves any config value found in the Blog s config . yml file .
19,004
private function configInfo ( $ table , $ path , $ name ) { if ( empty ( $ path ) ) { return array ( ) ; } if ( ! $ config = $ this -> config ( $ table , $ path ) ) { $ config = array ( ) ; } unset ( $ config [ 'path' ] , $ config [ 'url' ] ) ; $ page = Page :: html ( ) ; $ config = array_merge ( array ( 'name' => $ na...
Compiles an array of useful information .
19,005
private function normalizeFolders ( $ path = null ) { $ page = Page :: html ( ) ; $ dir = $ this -> folder . 'content/' ; if ( $ path && preg_match ( '/[^' . $ page -> url [ 'chars' ] . '\/]/' , $ path ) ) { $ seo = $ this -> url ( $ path , 'slashes' ) ; if ( is_dir ( $ dir . $ path ) ) { rename ( $ dir . $ path , $ di...
Recursively goes through the blog s content folder and fixes any malnamed directories .
19,006
public function setOrders ( $ value ) { if ( ! $ this -> _isNumericArray ( $ value ) ) { $ value = array ( $ value ) ; } $ this -> _fields [ 'Orders' ] [ 'FieldValue' ] = $ value ; return $ this ; }
Set the value of the Orders property .
19,007
public function setPromotionIds ( $ value ) { if ( ! $ this -> _isNumericArray ( $ value ) ) { $ value = array ( $ value ) ; } $ this -> _fields [ 'PromotionIds' ] [ 'FieldValue' ] = $ value ; return $ this ; }
Set the value of the PromotionIds property .
19,008
static protected function get ( $ search , $ protocol = 'https' ) { $ vicopoUrl = $ protocol . '://vicopo.selfbuild.fr/search/' . urlencode ( $ search ) ; $ json = @ json_decode ( file_get_contents ( $ vicopoUrl ) ) ; if ( ! is_object ( $ json ) || ! isset ( $ json -> cities ) ) { throw new Exception ( "No valid answea...
Search on VICOPO server .
19,009
public function setTaxClassifications ( $ value ) { if ( ! $ this -> _isNumericArray ( $ value ) ) { $ value = array ( $ value ) ; } $ this -> _fields [ 'TaxClassifications' ] [ 'FieldValue' ] = $ value ; return $ this ; }
Set the value of the TaxClassifications property .
19,010
public function normalize ( Scope $ head , Scope $ set , Lexer $ lexer ) { $ collection = array ( ) ; $ unicode = new Unicode ( ) ; while ( $ lexer -> moveNext ( ) && ! $ lexer -> isNextToken ( Lexer :: T_SET_CLOSE ) ) { $ value = null ; switch ( true ) { case ( $ lexer -> isNextTokenAny ( array ( Lexer :: T_SHORT_UNIC...
Will return a normalized ie unicode sequences been evaluated .
19,011
public function fillRange ( Scope $ head , $ start , $ end ) { $ start_index = Utf8 :: ord ( $ start ) ; $ ending_index = Utf8 :: ord ( $ end ) ; if ( $ ending_index < $ start_index ) { throw new ParserException ( sprintf ( 'Character class range %s - %s is out of order' , $ start , $ end ) ) ; } for ( $ i = $ start_in...
Fill a range given starting and ending character
19,012
public function generate ( & $ result , GeneratorInterface $ generator ) { if ( $ this -> literals -> count ( ) === 0 ) { throw new GeneratorException ( 'There are no literals to choose from' ) ; } $ repeat_x = $ this -> calculateRepeatQuota ( $ generator ) ; while ( $ repeat_x > 0 ) { $ randomIndex = 0 ; if ( $ this -...
Generate a text string appending to the result argument
19,013
public function setProxyAuth ( $ user , $ password ) { $ this -> setProxyUser ( $ user ) ; $ this -> setProxyPassword ( $ password ) ; return $ this ; }
Set proxy auth data
19,014
private function prepareAssets ( array $ assets ) : array { $ result = [ ] ; foreach ( $ assets as $ name ) { $ result [ ] = $ this -> getRealFilename ( $ name ) ; } return $ result ; }
Resolve real asset filenames .
19,015
private function getRealFilename ( string $ file ) : string { if ( strpos ( $ file , 'vfs://' ) !== false ) { return $ file ; } return $ this -> loader -> getSourceContext ( $ file ) -> getPath ( ) ; }
Returns full path and filename .
19,016
public function setLabel ( $ label ) { if ( ! ( is_scalar ( $ label ) || is_null ( $ label ) ) ) { return false ; } $ this -> label = $ label ; }
Sets the node label
19,017
public function & detach ( Node $ node ) { foreach ( $ this -> links as $ linked_node ) { if ( $ linked_node == $ node ) { $ this -> links -> detach ( $ node ) ; } } return $ this ; }
Detach a node
19,018
public function contains ( Node $ node ) { foreach ( $ this -> links as $ linked_node ) { if ( $ linked_node == $ node ) { return true ; } } return false ; }
Search for node in its relations
19,019
public function compress ( ) { $ current = $ this -> lexer -> lookahead [ 'position' ] ; $ this -> lexer -> reset ( ) ; $ string = '' ; while ( $ this -> lexer -> moveNext ( ) && $ this -> lexer -> lookahead [ 'position' ] <= $ current ) { $ string .= $ this -> lexer -> lookahead [ 'value' ] ; } return $ string ; }
Compress the lexer into value string until current lookahead
19,020
static function createSubParser ( $ name ) { if ( isset ( self :: $ sub_parsers [ $ name ] ) === false ) { throw new ParserException ( 'Unknown subparser at ' . $ name ) ; } if ( is_object ( self :: $ sub_parsers [ $ name ] ) === false ) { self :: $ sub_parsers [ $ name ] = new self :: $ sub_parsers [ $ name ] ( ) ; } ...
Return an instance os subparser
19,021
public function parse ( Scope $ head , Scope $ set , Lexer $ lexer ) { switch ( true ) { case ( $ lexer -> isNextToken ( Lexer :: T_DOT ) ) : $ this -> convertDotToRange ( $ head , $ set , $ lexer ) ; break ; case ( $ lexer -> isNextToken ( Lexer :: T_SHORT_D ) ) : case ( $ lexer -> isNextToken ( Lexer :: T_SHORT_NOT_D...
Parse the current token for Short Codes . \ d \ w
19,022
public function seed ( $ seed = null ) { if ( $ seed === null ) { $ seed = 0 ; } return $ this -> seed = abs ( intval ( $ seed ) ) % 9999999 + 1 ; }
Set the seed to use for generator
19,023
public function generate ( $ min = 0 , $ max = null ) { if ( $ max === null ) { $ max = 2796203 ; } if ( $ max > 2796203 ) { throw new ReverseRegexException ( 'Max param has exceeded the maxium 2796203' ) ; } if ( $ this -> seed == 0 ) { $ this -> seed ( mt_rand ( ) ) ; } $ this -> seed = ( $ this -> seed * 125 ) % 279...
Generate a random numer
19,024
public function mt ( $ index = null , $ min = 0 , $ max = 1000 ) { static $ op = array ( 0x0 , 0x9908b0df ) ; static $ mt = array ( ) ; if ( $ this -> seed !== $ this -> ps ) { $ s = $ this -> seed & 0xffffffff ; $ mt = array ( & $ s , 624 => & $ s ) ; $ this -> ps = $ this -> seed ; for ( $ i = 1 ; $ i < 624 ; ++ $ i ...
Mersenne Twister Random Number Generator Returns a random number . Depending on the application you likely don t have to reseed every time as you can simply select a different index from the last seed and get a different number .
19,025
public function generate ( & $ result , GeneratorInterface $ generator ) { if ( $ this -> count ( ) === 0 ) { throw new GeneratorException ( 'No child scopes to call must be atleast 1' ) ; } $ repeat_x = $ this -> calculateRepeatQuota ( $ generator ) ; $ this -> rewind ( ) ; while ( $ repeat_x > 0 ) { if ( $ this -> us...
Generate a text string appending to result arguments
19,026
public function get ( $ index ) { if ( $ index > $ this -> count ( ) || $ index <= 0 ) { return null ; } $ this -> rewind ( ) ; while ( ( $ index - 1 ) > 0 ) { $ this -> next ( ) ; $ index = $ index - 1 ; } return $ this -> current ( ) ; }
Fetch a node given an one - based index
19,027
public function setMaxOccurances ( $ num ) { if ( is_integer ( $ num ) === false ) { throw new GeneratorException ( 'Number must be an integer' ) ; } $ this [ self :: REPEAT_MAX_INDEX ] = $ num ; }
Sets the maximum re - occurances
19,028
public function setMinOccurances ( $ num ) { if ( is_integer ( $ num ) === false ) { throw new GeneratorException ( 'Number must be an integer' ) ; } $ this [ self :: REPEAT_MIN_INDEX ] = $ num ; }
Sets the Minimum number of re - occurances
19,029
public function calculateRepeatQuota ( GeneratorInterface $ generator ) { $ repeat_x = $ this -> getMinOccurances ( ) ; if ( $ this -> getOccuranceRange ( ) > 0 ) { $ repeat_x = ( integer ) \ round ( $ generator -> generate ( $ this -> getMinOccurances ( ) , $ this -> getMaxOccurances ( ) ) ) ; } return $ repeat_x ; }
Calculate a random numer of repeats given the current min - max range
19,030
public function assets ( ) { $ params = func_get_args ( ) ; $ assets = $ params [ 0 ] [ 'files' ] ; unset ( $ params [ 0 ] [ 'files' ] ) ; $ options = $ params [ 0 ] ; return $ this -> engine -> assets ( $ assets , $ options ) ; }
Assets function .
19,031
private function removeDirectory ( string $ path ) : bool { $ iterator = new DirectoryIterator ( $ path ) ; foreach ( $ iterator as $ fileInfo ) { if ( $ fileInfo -> isDot ( ) || ! $ fileInfo -> isDir ( ) ) { continue ; } $ dirName = $ fileInfo -> getPathname ( ) ; $ this -> removeDirectory ( $ dirName ) ; } $ files = ...
Remove directory recursively . This function is compatible with vfsStream .
19,032
public function create ( $ type , $ seed = null ) { $ type = strtolower ( $ type ) ; if ( isset ( self :: $ types [ $ type ] ) === true ) { if ( class_exists ( self :: $ types [ $ type ] ) === false ) { throw new ReverseRegexException ( 'Unknown Generator at::' . $ type ) ; } $ type = self :: $ types [ $ type ] ; } els...
Resolve a Dcotrine DataType Class
19,033
public function sort ( ) { $ values = $ this -> toArray ( ) ; ksort ( $ values ) ; $ this -> clear ( ) ; foreach ( $ values as $ index => $ value ) { $ this -> set ( $ index , $ value ) ; } return $ this ; }
Sort the values using a ksort
19,034
public function getAt ( $ position ) { if ( $ position < $ this -> count ( ) && $ position < 0 ) { return null ; } $ this -> first ( ) ; while ( $ position > 1 ) { $ this -> next ( ) ; -- $ position ; } return $ this -> current ( ) ; }
Fetch a value using ones based position
19,035
public function quantifyPlus ( Scope $ head , Scope $ result , Lexer $ lexer ) { $ min = 1 ; $ max = PHP_INT_MAX ; $ head -> setMaxOccurances ( $ max ) ; $ head -> setMinOccurances ( $ min ) ; return $ head ; }
Parse the current token for + quantifiers
19,036
public function quantifyQuestion ( Scope $ head , Scope $ result , Lexer $ lexer ) { $ min = 0 ; $ max = 1 ; $ head -> setMaxOccurances ( $ max ) ; $ head -> setMinOccurances ( $ min ) ; return $ head ; }
Parse the current token for ? quantifiers
19,037
public function seed ( $ seed = null ) { $ this -> seed = $ seed ; srand ( $ this -> seed ) ; return $ this ; }
Set the seed to use
19,038
public function evaluate ( Lexer $ lexer ) { switch ( true ) { case ( $ lexer -> isNextToken ( Lexer :: T_SHORT_P ) ) : throw new ParserException ( 'Property \p (Unicode Property) not supported use \x to specify unicode character or range' ) ; break ; case ( $ lexer -> isNextToken ( Lexer :: T_SHORT_UNICODE_X ) ) : $ l...
Parse a reference
19,039
public function login ( $ username , $ email ) { $ password = $ this -> createPassword ( $ username ) ; $ token = $ this -> getToken ( $ username , $ password ) ; if ( empty ( $ token ) ) { $ this -> signup ( $ username , $ password , $ email ) ; $ token = $ this -> getToken ( $ username , $ password ) ; } $ this -> se...
Call this method after your user is successfully authenticated .
19,040
public function onBeforeWrite ( ) { parent :: onBeforeWrite ( ) ; if ( empty ( $ this -> Title ) ) { $ type = $ this -> Type ; switch ( $ type ) { case 'URL' : case 'Email' : case 'Phone' : $ this -> Title = $ this -> getField ( $ type ) ; break ; case 'SiteTree' : $ this -> Title = $ this -> SiteTree ( ) -> MenuTitle ...
Event handler called before writing to the database . If the title is empty set a default based on the link .
19,041
public function gqlFields ( ) { $ fields = $ this -> config ( ) -> get ( 'gql_fields' ) ; $ this -> extend ( 'updateGqlFields' , $ fields ) ; $ fields = array_merge ( [ 'LinkURL' ] , $ fields ) ; return $ fields ; }
Provides a quick way to define additional methods to provideGraphQLScaffolding as Fields
19,042
public function geti18nTypes ( ) { $ i18nTypes = [ ] ; foreach ( $ this -> Types as $ key => $ label ) { $ i18nTypes [ $ key ] = _t ( __CLASS__ . '.TYPE' . strtoupper ( $ key ) , $ label ) ; } $ this -> extend ( 'updatei18nTypes' , $ i18nTypes ) ; return $ i18nTypes ; }
Returns allowed link types with translations
19,043
public function geti18nStyles ( ) { $ i18nStyles = [ ] ; foreach ( $ this -> styles as $ key => $ label ) { $ i18nStyles [ $ key ] = _t ( __CLASS__ . '.STYLE' . strtoupper ( $ key ) , $ label ) ; } $ this -> extend ( 'updatei18nStyles' , $ i18nStyles ) ; return $ i18nStyles ; }
Returns available styles with translations
19,044
public function getClass ( ) { if ( $ this -> style ) { $ this -> setClass ( $ this -> style ) ; } $ classes = $ this -> classes ; $ this -> extend ( 'updateClasses' , $ classes ) ; if ( Count ( $ classes ) ) { return implode ( ' ' , $ classes ) ; } }
Returns the css classes
19,045
public function getCurrentPage ( ) { $ currentPage = Director :: get_current_page ( ) ; if ( $ currentPage instanceof ContentController ) { $ currentPage = $ currentPage -> data ( ) ; } return $ currentPage ; }
Returns the current page scope
19,046
public function LinkingMode ( ) { if ( $ this -> isCurrent ( ) ) { return $ this -> config ( ) -> get ( 'linking_mode_current' ) ; } elseif ( $ this -> isSection ( ) ) { return $ this -> config ( ) -> get ( 'linking_mode_section' ) ; } else { return $ this -> config ( ) -> get ( 'linking_mode_default' ) ; } }
Return link current or section depending on if this page is the current page or not on the current page but in the current section .
19,047
public function getTypeLabel ( ) { $ types = $ this -> config ( ) -> get ( 'types' ) ; return isset ( $ types [ $ this -> Type ] ) ? _t ( __CLASS__ . '.TYPE' . strtoupper ( $ this -> Type ) , $ types [ $ this -> Type ] ) : null ; }
Returns the description label of this links type
19,048
public function forTemplate ( ) { $ link = '' ; if ( $ this -> LinkURL ) { $ link = $ this -> renderWith ( $ this -> RenderTemplates ) ; } $ this -> extend ( 'updateTemplate' , $ link ) ; return $ link ; }
Renders an HTML anchor attribute for this link
19,049
public static function get ( $ key = '' ) { if ( isset ( $ _COOKIE [ self :: $ prefix . $ key ] ) ) { return $ _COOKIE [ self :: $ prefix . $ key ] ; } return ( isset ( $ _COOKIE ) && count ( $ _COOKIE ) ) ? $ _COOKIE : false ; }
Get item from cookie .
19,050
public static function pull ( $ key ) { if ( isset ( $ _COOKIE [ self :: $ prefix . $ key ] ) ) { setcookie ( self :: $ prefix . $ key , '' , time ( ) - 3600 , '/' ) ; return $ _COOKIE [ self :: $ prefix . $ key ] ; } return false ; }
Extract item from cookie then delete cookie and return the item .
19,051
public static function destroy ( $ key = '' ) { if ( isset ( $ _COOKIE [ self :: $ prefix . $ key ] ) ) { setcookie ( self :: $ prefix . $ key , '' , time ( ) - 3600 , '/' ) ; return true ; } if ( count ( $ _COOKIE ) > 0 ) { foreach ( $ _COOKIE as $ key => $ value ) { setcookie ( $ key , '' , time ( ) - 3600 , '/' ) ; ...
Empties and destroys the cookies .
19,052
public static function setPrefix ( $ prefix ) { if ( ! empty ( $ prefix ) && is_string ( $ prefix ) ) { self :: $ prefix = $ prefix ; return true ; } return false ; }
Set cookie prefix .
19,053
public function historical ( $ date , $ base = 'EUR' , $ targets = [ ] ) { $ this -> date ( $ date ) ; return $ this -> latest ( $ base , $ targets ) ; }
Unsupported by Yahoo Finance API .
19,054
protected function query ( $ yql ) { $ params = $ this -> urlParams ; $ params [ 'q' ] = $ yql ; $ url = $ this -> url . '?' . http_build_query ( $ params ) ; try { $ response = $ this -> guzzle -> request ( 'GET' , $ url ) ; } catch ( TransferException $ e ) { throw new ConnectionException ( $ e -> getMessage ( ) ) ; ...
Perform the API query and return results as an array .
19,055
protected static function targetsToString ( $ targets , $ prefix = '' , $ suffix = '' ) { $ array = [ ] ; foreach ( $ targets as $ currency ) { $ array [ ] = '"' . $ prefix . $ currency . $ suffix . '"' ; } return implode ( ', ' , $ array ) ; }
Convert targets array to string for using in the YQL query .
19,056
public function target ( $ currencies ) { if ( ! is_array ( $ currencies ) ) { $ currencies = [ $ currencies ] ; } $ this -> targets = $ currencies ; return $ this ; }
Set the target currencies .
19,057
public function get ( ) { if ( $ this -> date ) { $ result = $ this -> historical ( $ this -> date , $ this -> base , $ this -> targets ) ; } else { $ result = $ this -> latest ( $ this -> base , $ this -> targets ) ; } if ( ! $ result instanceof ResultContract ) { throw new UnexpectedValueException ( 'Invalid result t...
Query the API .
19,058
protected static function updateBootstrapping ( ) { copy ( __DIR__ . '/uikit-stubs/webpack.mix.js' , base_path ( 'webpack.mix.js' ) ) ; if ( ! self :: expectsAssetsFolder ( ) ) { file_put_contents ( base_path ( 'webpack.mix.js' ) , str_replace ( 'assets/' , '' , file_get_contents ( base_path ( 'webpack.mix.js' ) ) ) ) ...
Update the bootstrapping files .
19,059
public function decimal ( $ values , string $ currency = null , int $ decimal_points = 2 ) : string { [ $ className , $ value ] = $ this -> classAndValue ( $ values , $ currency ) ; return ( new $ className ) -> decimal ( $ value , $ decimal_points ) ; }
Convert value to decimal .
19,060
public function integer ( $ values , string $ currency = null ) : int { [ $ className , $ value ] = $ this -> classAndValue ( $ values , $ currency , false ) ; return ( new $ className ) -> integer ( $ value ) ; }
Convert value to integer .
19,061
public function withPostfix ( $ values , string $ currency = null , int $ decimal_points = null ) : string { [ $ className , $ value ] = $ this -> classAndValue ( $ values , $ currency ) ; return ( new $ className ) -> postfix ( $ value , $ decimal_points ) ; }
Display value as decimal with currency label .
19,062
public function withPrefixAndPostfix ( $ values , string $ currency = null , int $ decimal_points = null ) : string { [ $ className , $ value ] = $ this -> classAndValue ( $ values , $ currency ) ; return ( new $ className ) -> prefixPostfix ( $ value , $ decimal_points ) ; }
Display value as decimal with currency symbol and label .
19,063
private function classAndValue ( $ values , string $ currency = null , bool $ asFloat = true ) : array { $ className = $ this -> getClass ( $ currency ) ; $ value = is_array ( $ values ) ? $ this -> getValue ( $ values , $ currency ) : $ values ; if ( $ asFloat && $ this -> provider -> config -> value_as_integer ) { $ ...
Get class and value .
19,064
public function options ( ) : array { $ currencies = $ this -> provider -> config -> get ( 'currencies' ) ; $ options = [ ] ; foreach ( $ currencies as $ key => $ currency ) { $ options [ ] = new Option ( $ key , new $ currency ) ; } return $ options ; }
Get a an array of available currencies .
19,065
public function value ( float $ value , int $ decimal_points = null ) : string { if ( is_null ( $ decimal_points ) ) { return $ value ; } return $ this -> decimal ( $ value , $ decimal_points ) ; }
Get formatted value .
19,066
public function get ( $ id = null ) { if ( ! is_null ( $ id ) ) { return $ this -> find ( $ id ) ; } return $ this -> model -> get ( ) ; }
Get a single item or collection
19,067
public function getTrash ( $ id = null ) { if ( ! is_null ( $ id ) ) { return $ this -> getTrashedItem ( $ id ) ; } return $ this -> model -> onlyTrashed ( ) -> get ( ) ; }
Retrieve single trashed item or all
19,068
public function orderBy ( $ field , $ order = 'asc' ) { $ this -> model = $ this -> model -> orderBy ( ... func_get_args ( ) ) ; return $ this ; }
Order the collection you pull
19,069
public function create ( array $ data ) { $ model = $ this -> model -> create ( $ data ) ; if ( $ this -> validateRelationData ( $ this -> withHasMany , 'many' ) ) { $ model -> { $ this -> withHasMany [ 'relation' ] } ( ) -> saveMany ( $ this -> withHasMany [ 'data' ] ) ; } if ( $ this -> validateRelationData ( $ this ...
Create new database entry including related models
19,070
public function delete ( $ id , $ hardDelete = false ) { if ( $ hardDelete ) { return $ this -> model -> withTrashed ( ) -> find ( $ id ) -> forceDelete ( $ id ) ; } return $ this -> model -> find ( $ id ) -> delete ( $ id ) ; }
Delete model either soft or hard delete
19,071
public function withHasMany ( array $ data , $ relatedModel , $ relation_name ) { $ this -> withHasMany [ 'relation' ] = $ relation_name ; foreach ( $ data as $ k => $ v ) { $ this -> withHasMany [ 'data' ] [ ] = new $ relatedModel ( $ v ) ; } return $ this ; }
Set related models that need to be created for a hasMany relationship
19,072
public function handleUpload ( \ Illuminate \ Http \ Request $ request , $ fieldname = 'photo' , $ folder = 'images' , $ storage_disk = 'public' , $ randomize = true ) { if ( is_null ( $ request -> file ( $ fieldname ) ) || ! $ request -> file ( $ fieldname ) -> isValid ( ) ) { throw new \ Exception ( trans ( 'crud.inv...
Handle a file upload
19,073
public function processTranslations ( array $ translations , $ trans_key = null , $ language_key = 'language_id' ) { $ approved = [ ] ; foreach ( $ translations as $ trans ) { if ( ! is_array ( $ trans ) ) { continue ; } if ( ! is_null ( $ trans_key ) ) { unset ( $ trans [ $ trans_key ] ) ; } if ( ! isset ( $ this -> r...
Process translation input data for saving them .
19,074
public function saveTranslations ( \ Illuminate \ Database \ Eloquent \ Model $ model , array $ translations ) { if ( empty ( $ translations ) ) throw new MissingTranslationsException ; if ( empty ( $ this -> translation_name ) ) throw new MissingTranslationNameException ; return $ model -> { $ this -> translation_name...
Save translations to model
19,075
public function checkRequired ( array $ arr ) { $ filtered = $ this -> filterNull ( $ arr ) ; if ( isset ( $ this -> required_trans ) ) throw new MissingRequiredFieldsException ; return count ( array_intersect_key ( array_flip ( $ this -> required_trans ) , $ filtered ) ) === count ( $ this -> required_trans ) ; }
If you set the required fields in your service class you can check if these fields were set .
19,076
protected function replaceServiceVar ( $ name ) { $ class = str_replace ( $ this -> getNamespace ( $ name ) . '\\' , '' , $ name ) ; $ class = strtolower ( snake_case ( str_replace ( 'Service' , '' , $ class ) ) ) ; return str_plural ( $ class ) ; }
Replace the service variable in the stub using pluralization
19,077
protected function replaceSingularServiceVar ( $ name ) { $ class = str_replace ( $ this -> getNamespace ( $ name ) . '\\' , '' , $ name ) ; $ class = strtolower ( snake_case ( str_replace ( 'Service' , '' , $ class ) ) ) ; return $ class ; }
Replace the service variable in stubs in singular
19,078
public static function stem ( $ word , $ language ) { if ( empty ( $ language ) ) { return $ word ; } foreach ( static :: $ classMap as $ stemmer => $ languages ) { if ( in_array ( $ language , $ languages ) ) { return $ stemmer :: stem ( $ word ) ; } } return $ word ; }
Stem a word .
19,079
public static function stemPhrase ( $ phares , $ language ) { $ words = [ ] ; foreach ( explode ( " " , $ phares ) as $ word ) { $ words [ ] = static :: stem ( $ word , $ language ) ; } return implode ( " " , $ words ) ; }
Stem a phrase by its words .
19,080
public function setRPCNotification ( $ notification ) { empty ( $ notification ) ? $ this -> notification = false : $ this -> notification = true ; }
Sets the notification state of the object . In this state notifications are performed instead of requests .
19,081
public static function Stem ( $ word ) { if ( strlen ( $ word ) <= 2 ) { return $ word ; } $ word = self :: step1ab ( $ word ) ; $ word = self :: step1c ( $ word ) ; $ word = self :: step2 ( $ word ) ; $ word = self :: step3 ( $ word ) ; $ word = self :: step4 ( $ word ) ; $ word = self :: step5 ( $ word ) ; return $ w...
Stems a word . Simple huh?
19,082
protected function registerCommands ( ) { $ this -> app -> singleton ( 'command.verification.make' , function ( $ app ) { return new MakeVerificationCommand ( $ app [ 'composer' ] ) ; } ) ; $ this -> app -> singleton ( 'command.verification.clear' , function ( $ app ) { return new ClearVerificationTokensCommand ( ) ; }...
Register the related console commands .
19,083
protected function createMigrations ( ) { file_put_contents ( $ this -> createUsersVerificationsMigration ( ) , file_get_contents ( __DIR__ . '/stubs/migrations/users_verifications.stub' ) ) ; file_put_contents ( $ this -> createUsersMigration ( ) , file_get_contents ( __DIR__ . '/stubs/migrations/users.stub' ) ) ; $ t...
Create migrations .
19,084
protected function createUsersVerificationsMigration ( ) { $ name = 'create_users_verifications_table' ; $ path = $ this -> laravel -> databasePath ( ) . '/migrations' ; return $ this -> laravel [ 'migration.creator' ] -> create ( $ name , $ path ) ; }
Create a base migration file for the verifications table .
19,085
protected function createUsersMigration ( ) { $ name = 'add_verified_columns_to_users_table' ; $ path = $ this -> laravel -> databasePath ( ) . '/migrations' ; return $ this -> laravel [ 'migration.creator' ] -> create ( $ name , $ path ) ; }
Create a base migration file for the users table .
19,086
public function sendVerificationLink ( array $ credentials , Closure $ callback = null ) { $ user = $ this -> getUser ( $ credentials ) ; if ( is_null ( $ user ) ) { return Contracts \ VerificationBroker :: INVALID_USER ; } $ token = $ this -> tokens -> create ( $ user ) ; $ this -> emailVerificationLink ( $ user , $ t...
Send a user verification link .
19,087
public function verify ( array $ credentials , Closure $ callback ) { $ user = $ this -> validateVerification ( $ credentials ) ; if ( ! $ user instanceof Contracts \ RequiresEmailVerification ) { return $ user ; } call_user_func ( $ callback , $ user ) ; $ this -> tokens -> delete ( $ credentials [ 'token' ] ) ; retur...
Verify given account .
19,088
protected function validateVerification ( array $ credentials ) { if ( is_null ( $ user = $ this -> getUser ( $ credentials ) ) ) { return Contracts \ VerificationBroker :: INVALID_USER ; } if ( ! $ this -> tokens -> exists ( $ user , $ credentials [ 'token' ] ) ) { return Contracts \ VerificationBroker :: INVALID_TOKE...
Validate verification for the given credentials .
19,089
public function broker ( $ name = null ) { $ name = $ name ? : $ this -> getDefaultDriver ( ) ; return $ this -> brokers [ $ name ] = $ this -> get ( $ name ) ; }
Get a verification broker instance by name .
19,090
protected function createUsersBroker ( array $ config ) { return new VerificationBroker ( $ this -> createTokenRepository ( $ this -> app [ 'config' ] [ 'verification.repositories.' . $ config [ 'repository' ] ] ) , $ this -> app [ 'auth' ] -> createUserProvider ( $ config [ 'provider' ] ) , $ this -> app [ 'mailer' ] ...
Create users broker .
19,091
protected function createDatabaseRepository ( array $ config ) { return new DatabaseTokenRepository ( $ this -> app [ 'db' ] -> connection ( $ config [ 'connection' ] ) , $ config [ 'table' ] , $ this -> app [ 'config' ] [ 'app.key' ] , $ config [ 'expires' ] ) ; }
Create database token repository .
19,092
protected function setParameters ( ) { $ parameters = [ ] ; $ parameters [ '-o' ] = Config :: get ( 'spy.output' , base_path ( 'database/schema' ) ) ; $ connections = Config :: get ( 'database.connections' , [ ] ) ; $ connection = ( $ this -> argument ( 'connection' ) ) ? : Config :: get ( 'database.default' ) ; if ( i...
Set schemaspy command parameters .
19,093
protected function verifyUser ( $ user ) { $ user -> verified = true ; $ user -> verified_at = new Carbon ( 'now' ) ; $ user -> save ( ) ; Auth :: guard ( $ this -> getGuard ( ) ) -> login ( $ user ) ; }
Verify user .
19,094
public function sendVerificationLinkEmail ( Request $ request ) { $ this -> validate ( $ request , [ 'email' => 'required|email' ] ) ; $ broker = $ this -> getBroker ( ) ; $ credentials = $ request -> only ( 'email' ) ; $ response = Verification :: broker ( $ broker ) -> sendVerificationLink ( $ credentials , function ...
Send a verification link to the given user .
19,095
protected function fetchActionScope ( $ actionId ) { if ( empty ( $ this -> actionScopes ) ) { return null ; } $ ownerId = $ this -> owner -> getUniqueId ( ) ; foreach ( $ this -> actionScopes as $ actionPattern => $ scope ) { if ( StringHelper :: matchWildcard ( "$ownerId/$actionPattern" , $ actionId ) ) { return $ sc...
Fetch the scope required for the action id .
19,096
public function verificationRedirectPath ( ) { if ( property_exists ( $ this , 'verificationRedirectPath' ) ) { return $ this -> verificationRedirectPath ; } return property_exists ( $ this , 'verificationRedirectTo' ) ? $ this -> verificationRedirectTo : route ( 'verification.verify' , [ ] , false ) ; }
Get the post register redirect path if user must verify account .
19,097
public function create ( Contracts \ RequiresEmailVerification $ user ) { $ email = $ user -> getEmailForVerification ( ) ; $ this -> deleteExisting ( $ user ) ; $ token = $ this -> createNewToken ( ) ; $ this -> getTable ( ) -> insert ( $ this -> getPayload ( $ email , $ token ) ) ; return $ token ; }
Create a new token .
19,098
public function authenticated ( Request $ request , Contracts \ RequiresEmailVerification $ user ) { if ( config ( 'verification.verify' ) && ! $ user -> isUserEmailVerified ( ) ) { Auth :: guard ( $ this -> getGuard ( ) ) -> logout ( ) ; return redirect ( $ this -> verificationRedirectPath ( ) ) ; } return redirect ( ...
Check if user is verified or not .
19,099
public function initOauth2Server ( ) { if ( $ this -> serverInitialized ) { return ; } $ this -> serverInitialized = true ; $ this -> modelMap = array_merge ( $ this -> defaultModelMap , $ this -> modelMap ) ; $ this -> storageMap = array_merge ( $ this -> defaultStorageMap , $ this -> storageMap ) ; foreach ( $ this -...
Initializes the oauth2 server and its dependencies .