idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
41,000 | protected function getPlaceholderFromArray ( array $ properties ) { if ( isset ( $ properties [ 'placeholder' ] ) && ! empty ( $ properties [ 'placeholder' ] ) ) { if ( is_array ( $ properties [ 'placeholder' ] ) ) { return $ this -> getLabelsFromArray ( $ properties [ 'placeholder' ] ) ; } return [ new Label ( $ prope... | It will get the provided labels for the placeholder |
41,001 | public function isOnView ( $ view ) { $ view = ucfirst ( strtolower ( $ view ) ) ; if ( in_array ( $ view , [ 'Form' , 'Index' , 'Show' ] ) ) { return $ this -> { 'isOn' . $ view . 'View' } ; } return false ; } | Checks if the field is on a given view . |
41,002 | public function addOption ( $ text , $ isPlain = true , $ lang = 'en' , $ value = null ) { $ id = $ this -> getFieldId ( $ value ) ; $ this -> options [ $ lang ] [ ] = new Label ( $ text , $ this -> getLocaleKey ( $ value ) , $ isPlain , $ lang , $ id , $ value ) ; } | Adds a label to the options collection |
41,003 | public function getOptionsByLang ( $ lang = 'en' ) { $ finalOptions = [ ] ; foreach ( $ this -> getOptions ( ) as $ options ) { foreach ( $ options as $ option ) { if ( $ option -> lang == $ lang || $ option -> isPlain ) { $ finalOptions [ ] = $ option ; } } } return empty ( $ finalOptions ) ? null : $ finalOptions ; } | Gets a options by a given language |
41,004 | public function getEloquentDataMethod ( ) { $ map = Config :: dataTypeMap ( ) ; if ( isset ( $ map [ $ this -> dataType ] ) ) { return $ map [ $ this -> dataType ] ; } return 'string' ; } | Gets Eloquent s method name |
41,005 | protected function getFieldId ( $ optionValue = null ) { if ( ! is_null ( $ optionValue ) ) { return sprintf ( '%s_%s' , $ this -> name , $ this -> cleanValue ( $ optionValue ) ) ; } return $ this -> name ; } | Gets the field Id . |
41,006 | public function toArray ( ) { return [ 'name' => $ this -> name , 'labels' => $ this -> labelsToRaw ( $ this -> getLabels ( ) ) , 'html-type' => $ this -> htmlType , 'css-class' => $ this -> cssClass , 'options' => $ this -> optionsToRaw ( $ this -> getOptions ( ) ) , 'html-value' => $ this -> htmlValue , 'validation' ... | Returns current object into an array . |
41,007 | protected function getRawDataType ( ) { $ type = array_search ( $ this -> getEloquentDataMethod ( ) , Config :: dataTypeMap ( ) ) ; return $ type !== false ? $ type : $ this -> dataType ; } | Gets the data type in a raw format . |
41,008 | public function setOnStore ( array $ properties ) { if ( array_key_exists ( 'on-store' , $ properties ) ) { $ this -> onStore = $ this -> getOnAction ( $ properties [ 'on-store' ] ) ; } return $ this ; } | Sets the raw php command to execute on create . |
41,009 | public function setRange ( array $ properties ) { if ( self :: isValidSelectRangeType ( $ properties ) ) { $ this -> range = explode ( ':' , substr ( $ properties [ 'html-type' ] , 12 ) ) ; } if ( Helpers :: isKeyExists ( $ properties , 'range' ) && is_array ( $ properties [ 'range' ] ) ) { $ this -> range = $ properti... | Sets the range for a given field |
41,010 | public function setOptionsProperty ( array $ properties ) { if ( Helpers :: isKeyExists ( $ properties , 'options' ) && is_array ( $ properties [ 'options' ] ) ) { $ labels = $ this -> transferOptionsToLabels ( $ properties [ 'options' ] ) ; foreach ( $ labels as $ label ) { $ this -> addOption ( $ label -> text , $ la... | It set the options property for a given field |
41,011 | protected function transferOptionsToLabels ( array $ options ) { $ finalOptions = [ ] ; $ index = 0 ; foreach ( $ options as $ value => $ option ) { if ( ! is_array ( $ option ) ) { $ finalOptions [ ] = new Label ( $ option , $ this -> localeGroup , true , $ this -> defaultLang , null , $ value ) ; continue ; } $ optio... | Transfers options array to array on Labels |
41,012 | public function setOnUpdate ( array $ properties ) { if ( array_key_exists ( 'on-update' , $ properties ) ) { $ this -> onUpdate = $ this -> getOnAction ( $ properties [ 'on-update' ] ) ; } return $ this ; } | Sets the raw php command to execute on update . |
41,013 | public function getOnAction ( $ action ) { $ action = trim ( $ action ) ; if ( empty ( $ action ) ) { return null ; } return Helpers :: postFixWith ( $ action , ';' ) ; } | Cleans up a given action |
41,014 | public function setDataTypeParams ( array $ properties ) { if ( Helpers :: isKeyExists ( $ properties , 'data-type-params' ) ) { $ this -> methodParams = $ this -> getDataTypeParams ( ( array ) $ properties [ 'data-type-params' ] ) ; } return $ this ; } | Sets the DataTypeParam for a given field |
41,015 | public function getDataTypeParams ( array $ params ) { $ type = $ this -> getEloquentDataMethod ( ) ; if ( in_array ( $ type , [ 'char' , 'string' ] ) && isset ( $ params [ 0 ] ) && ( $ length = intval ( $ params [ 0 ] ) ) > 0 ) { return [ $ length ] ; } if ( in_array ( $ type , [ 'decimal' , 'double' , 'float' ] ) && ... | Gets the data type parameters for the given type . |
41,016 | protected function setLabelsProperty ( array $ properties ) { $ labels = $ this -> getLabelsFromProperties ( $ properties ) ; foreach ( $ labels as $ label ) { $ this -> addLabel ( $ label -> text , $ label -> isPlain , $ label -> lang ) ; } return $ this ; } | It set the labels property for a given field |
41,017 | public function setUnsigned ( array $ properties ) { $ this -> isUnsigned = ( Helpers :: isKeyExists ( $ properties , 'is-unsigned' ) && $ properties [ 'is-unsigned' ] ) || in_array ( $ this -> getEloquentDataMethod ( ) , $ this -> unsignedTypes ) ; return $ this ; } | Sets the isUnsigned for a given field |
41,018 | protected function setForeignRelationFromArray ( array $ properties ) { if ( Helpers :: isKeyExists ( $ properties , 'is-foreign-relation' ) && ! $ properties [ 'is-foreign-relation' ] ) { return $ this ; } $ relation = ForeignRelationship :: predict ( $ this -> name , Helpers :: getModelsPath ( ) ) ; if ( Helpers :: i... | Sets the foreign relations for a given field |
41,019 | protected function setForeignConstraintFromArray ( array $ properties ) { $ foreignConstraint = $ this -> getForeignConstraintFromArray ( $ properties ) ; $ this -> setForeignConstraint ( $ foreignConstraint ) ; if ( $ this -> hasForeignConstraint ( ) && ! $ this -> hasForeignRelation ( ) ) { $ this -> setForeignRelati... | Sets the foreign key for a given field |
41,020 | protected function containsForeignConstraint ( array $ properties ) { return Helpers :: isKeyExists ( $ properties , 'foreign-constraint' ) && is_array ( $ properties [ 'foreign-constraint' ] ) && Helpers :: isKeyExists ( $ properties [ 'foreign-constraint' ] , 'field' , 'references' , 'on' ) ; } | Check if given properties contains a valid foreign key object |
41,021 | public function getDateValidationRule ( ) { if ( $ this -> isDateOrTime ( ) ) { if ( ! empty ( $ this -> dateFormat ) ) { return sprintf ( 'date_format:%s' , $ this -> dateFormat ) ; } return 'date' ; } return null ; } | Gets date validation rule for a datetime field . |
41,022 | public function getTrueBooleanOption ( ) { if ( ! $ this -> isBoolean ( ) ) { return null ; } $ options = $ this -> getOptionsByLang ( $ this -> defaultLang ) ; if ( isset ( $ options [ 1 ] ) ) { return $ options [ 1 ] ; } if ( isset ( $ options [ 0 ] ) ) { return $ options [ 0 ] ; } $ label = new Label ( 'Yes' , $ thi... | Gets the true label for the boolean field . |
41,023 | public function getFalseBooleanOption ( ) { if ( ! $ this -> isBoolean ( ) ) { return null ; } $ options = $ this -> getOptionsByLang ( $ this -> defaultLang ) ; if ( isset ( $ options [ 0 ] ) ) { return $ options [ 0 ] ; } return new Label ( 'No' , $ this -> getLocaleKey ( '' ) , true , 'en' , $ this -> getFieldId ( 0... | Gets the false label for the boolean field . |
41,024 | public function getMaxLength ( ) { if ( $ this -> isString ( ) && isset ( $ this -> methodParams [ 0 ] ) ) { return intval ( $ this -> methodParams [ 0 ] ) ; } return null ; } | Gets the Min length a field . |
41,025 | public function getMaxValue ( ) { if ( ! $ this -> isNumeric ( ) ) { return null ; } $ dataType = $ this -> getEloquentDataMethod ( ) ; $ max = 2147483647 ; if ( $ this -> isDecimal ( ) ) { $ length = $ this -> getMethodParam ( 0 ) ? : 1 ; $ declimal = $ this -> getMethodParam ( 1 ) ? : 0 ; $ max = str_repeat ( '9' , $... | Gets the maximum value a field can equal . |
41,026 | public function getMinValue ( ) { if ( $ this -> isUnsigned ) { return 0 ; } if ( ! is_null ( $ value = $ this -> getMaxValue ( ) ) ) { return ( $ value * - 1 ) - ( $ this -> isDecimal ( ) ? 0 : 1 ) ; } return null ; } | Gets the minimum value a field can equal . |
41,027 | protected function getMethodParam ( $ index ) { if ( isset ( $ this -> methodParams [ $ index ] ) && ( $ value = intval ( $ this -> methodParams [ $ index ] ) ) > 0 ) { return $ value ; } return null ; } | Gets method s parameter for a given index . |
41,028 | protected function labelsToRaw ( array $ labels ) { $ final = [ ] ; foreach ( $ labels as $ label ) { if ( $ label -> isPlain ) { return $ label -> text ; } $ final [ $ label -> lang ] = $ label -> text ; } return ( object ) $ final ; } | Gets current labels in a raw format . |
41,029 | protected function optionsToRaw ( array $ options ) { $ collections = [ ] ; foreach ( $ options as $ lang => $ labels ) { $ finalWithTranslations = [ ] ; foreach ( $ labels as $ label ) { if ( $ label -> isPlain ) { $ collections [ $ label -> value ] = $ label -> text ; } else { $ collections [ $ label -> lang ] [ $ la... | Gets current Options into a raw format . |
41,030 | public static function isValidHtmlType ( array $ properties ) { return Helpers :: isKeyExists ( $ properties , 'html-type' ) && ( in_array ( $ properties [ 'html-type' ] , self :: $ validHtmlTypes ) || self :: isValidSelectRangeType ( $ properties ) ) ; } | Checks if a field contains a valid html - type name |
41,031 | public static function getNameFromArray ( array $ properties ) { if ( ! Helpers :: isKeyExists ( $ properties , 'name' ) || empty ( $ fieldName = Helpers :: removeNonEnglishChars ( $ properties [ 'name' ] ) ) ) { throw new Exception ( "The field 'name' was not provided!" ) ; } return $ fieldName ; } | It gets the name of the field from a given array |
41,032 | protected function reduceFields ( & $ resource , array $ fieldNames ) { $ keep = [ ] ; $ totalReduced = 0 ; foreach ( $ resource -> fields as $ field ) { if ( in_array ( $ field -> name , $ fieldNames ) || in_array ( $ field -> name , $ keep ) ) { $ totalReduced ++ ; continue ; } $ keep [ ] = $ field ; } $ resource -> ... | Reduces the fields from a given resource . |
41,033 | protected function reduceIndexes ( & $ resource , array $ indexNames ) { $ keep = [ ] ; $ keepName = [ ] ; $ totalReduced = 0 ; foreach ( $ resource -> indexes as $ index ) { if ( in_array ( $ index -> getName ( ) , $ indexNames ) || in_array ( $ index -> getName ( ) , $ keepName ) ) { $ totalReduced ++ ; continue ; } ... | Reduces the indexes from a given resource . |
41,034 | protected function reduceRelations ( & $ resource , array $ relationNames ) { $ keep = [ ] ; $ keepName = [ ] ; $ totalReduced = 0 ; foreach ( $ resource -> relations as $ relation ) { if ( in_array ( $ relation -> getName ( ) , $ relationNames ) || in_array ( $ relation -> getName ( ) , $ keepName ) ) { $ totalReduced... | Reduces the relations from a given resource . |
41,035 | public function optimize ( ) { $ this -> optimizeStringField ( ) -> optimizeRequiredField ( ) -> optimizeDateFields ( ) -> optimizeBoolean ( ) -> optimizePrimaryKey ( ) -> optimizeValidations ( ) -> optimizeHtmlType ( ) -> addPlaceHolder ( ) ; return $ this ; } | Optimizes the field . |
41,036 | protected function optimizeStringField ( ) { if ( empty ( $ this -> field -> methodParams ) && in_array ( $ this -> field -> dataType , [ 'string' , 'char' ] ) && ! empty ( $ this -> parser -> getMaxLength ( ) ) ) { $ this -> field -> methodParams [ ] = $ this -> parser -> getMaxLength ( ) ; } return $ this ; } | If the data - type - params is not set and the dataType is string yet the validation rules has a max value create data - type - parameter |
41,037 | protected function optimizeRequiredField ( ) { if ( ! array_key_exists ( 'is-nullable' , $ this -> meta ) && ! $ this -> field -> isPrimary ( ) && ( $ this -> parser -> isNullable ( ) || ! $ this -> parser -> isRequired ( ) || $ this -> parser -> isConditionalRequired ( ) ) ) { $ this -> field -> isNullable = true ; } ... | If the field is not required well make it nullable |
41,038 | protected function optimizeDateFields ( ) { if ( empty ( $ this -> field -> dateFormat ) && $ this -> field -> isDateOrTime ( ) ) { $ this -> field -> dateFormat = Config :: getDateTimeFormat ( ) ; } return $ this ; } | If the field is date datetime or time set the output format . |
41,039 | protected function addPlaceHolder ( ) { if ( empty ( $ this -> field -> placeHolder ) && $ this -> field -> hasForeignRelation ( ) ) { $ this -> field -> placeHolder = 'Please select a ' . $ this -> field -> getForeignRelation ( ) -> name ; } return $ this ; } | If the field has a relation and the placeholder is missing add generic one . |
41,040 | protected function optimizeValidations ( ) { if ( ! $ this -> field -> isNullable && ! in_array ( 'required' , $ this -> field -> validationRules ) ) { array_unshift ( $ this -> field -> validationRules , 'required' ) ; } if ( ( $ rule = $ this -> field -> getDateValidationRule ( ) ) != null && ! in_array ( $ rule , $ ... | If the field is not visible on the form view clear the validation . |
41,041 | protected function optimizePrimaryKey ( ) { if ( $ this -> field -> isPrimary ( ) ) { $ this -> field -> isNullable = false ; if ( $ this -> meta == null ) { $ this -> field -> isOnFormView = false ; $ this -> field -> isOnIndexView = false ; $ this -> field -> isOnShowView = false ; return $ this ; } if ( ! array_key_... | If the property name is id or if the field is primary or autoincrement . Ensure the datatype is set to be valid otherwise make it int . It also make sure the primary column does not appears on the views unless it specified |
41,042 | protected function getPaths ( ) { $ directory = new RecursiveDirectoryIterator ( $ this -> getMigrationPath ( ) ) ; $ iterator = new RecursiveIteratorIterator ( $ directory ) ; $ paths = [ ] ; foreach ( $ iterator as $ info ) { if ( $ info -> isDir ( ) ) { $ paths [ ] = $ info -> getPath ( ) ; } } return array_unique (... | Recursively get all of the migration paths . |
41,043 | public function isRenamed ( ) { if ( $ this -> hasFromToFields ( ) && $ this -> fromField -> name !== $ this -> toField -> name ) { return true ; } return false ; } | Check whether or not the field has a name change |
41,044 | public function toArray ( ) { return [ 'field' => $ this -> getRawProperty ( 'field' ) , 'from-field' => $ this -> getRawProperty ( 'fromField' ) , 'to-field' => $ this -> getRawProperty ( 'toField' ) , 'is-deleted' => $ this -> isDeleted , 'is-added' => $ this -> isAdded , ] ; } | Return current object as an array . |
41,045 | protected function getFieldItems ( Field $ field ) { if ( $ field -> hasForeignRelation ( ) && $ field -> isOnFormView ) { return sprintf ( '$%s' , $ field -> getForeignRelation ( ) -> getCollectionName ( ) ) ; } $ labels = $ field -> getOptionsByLang ( ) ; return sprintf ( '[%s]' , implode ( ',' . PHP_EOL , $ this -> ... | It gets converts an array to a string based array for the views . |
41,046 | protected function getFieldValue ( $ value , $ name ) { if ( ! is_null ( $ value ) ) { $ modelVariable = $ this -> getSingularVariable ( $ this -> modelName ) ; return sprintf ( "(!isset(\$%s->%s) ? '%s' : null)" , $ modelVariable , $ name , $ value ) ; } return 'null' ; } | Gets the fields value |
41,047 | protected function getCheckedItem ( $ value , $ name , $ defaultValue ) { return sprintf ( " (%s == '%s' ? true : null) " , $ this -> getRawOptionValue ( $ name , $ defaultValue ) , $ value ) ; } | Gets checked item attribute . |
41,048 | protected function getMultipleCheckedItem ( $ value , $ name , $ defaultValue ) { return sprintf ( " (%s ? true : null) " , $ this -> getMultipleRawOptionValue ( $ name , $ value , $ defaultValue ) ) ; } | Gets multiple - checked item attribute . |
41,049 | public function getPluralVariable ( $ name ) { $ snake = snake_case ( $ name ) ; $ variableName = camel_case ( Str :: plural ( $ snake ) ) ; if ( $ variableName == $ this -> getSingularVariable ( $ name ) ) { $ variableName .= 'Objects' ; } return $ variableName ; } | Gets plural variable instance of a given model . |
41,050 | protected function getIndent ( $ stub , $ template ) { $ lines = explode ( "\n" , $ stub ) ; foreach ( $ lines as $ line ) { if ( ( $ index = strpos ( $ line , $ template ) ) !== false ) { return $ index ; } } return 0 ; } | Gets the indentation count . |
41,051 | public function generatorOption ( $ key ) { $ value = $ this -> option ( $ key ) ; if ( is_string ( $ value ) ) { $ value = trim ( $ value ) ; return in_array ( $ value , $ this -> noValues ) ? null : $ value ; } return $ value ; } | Override Laravel s option method |
41,052 | protected function replaceViewNames ( & $ stub , $ viewDirectory , $ routesPrefix , array $ views = null ) { foreach ( ( $ views ? : $ this -> views ) as $ view ) { $ viewName = $ this -> getDotNotationName ( $ viewDirectory , $ routesPrefix , $ view ) ; $ viewTemplate = $ this -> getViewTemplateName ( $ view ) ; $ stu... | It Replaces the view names in a given stub |
41,053 | protected function getDotNotationName ( $ viewDirectory , $ routesPrefix , $ name = 'index' ) { if ( ! empty ( $ viewDirectory ) ) { $ name = Helpers :: getWithDotPostFix ( Helpers :: convertToDotNotation ( $ viewDirectory ) ) . $ name ; } if ( ! empty ( $ routesPrefix ) ) { $ routesPrefix = str_replace ( '.' , '-' , $... | Gets a full name with dot notation |
41,054 | protected function replaceRouteNames ( & $ stub , $ modelName , $ routesPrefix , array $ actions = null ) { foreach ( ( $ actions ? : $ this -> actions ) as $ action ) { $ routeName = $ this -> getDotNotationName ( $ modelName , $ routesPrefix , $ action ) ; $ routeTemplate = $ this -> getRouteName ( $ action ) ; $ stu... | Replaces the route names for all the provided actions |
41,055 | protected function getStubContent ( $ name , $ template = null ) { return $ this -> getFileContent ( $ this -> getStubByName ( $ name , $ template ? : $ this -> getTemplateName ( ) ) ) ; } | Gets the content of a stub |
41,056 | protected function getPrimaryField ( array $ fields ) { foreach ( $ fields as $ field ) { if ( $ this -> isField ( $ field ) && ( $ field -> isPrimary || $ field -> isAutoIncrement ) ) { return $ field ; } } return null ; } | Determine the primary field in a given array |
41,057 | protected function getHeaderField ( array $ fields ) { foreach ( $ fields as $ field ) { if ( $ this -> isField ( $ field ) && $ field -> isHeader ) { return $ field ; } } return null ; } | Determine the field to be used for header from the givin fields . |
41,058 | protected function createFile ( $ file , $ stub ) { $ path = dirname ( $ file ) ; $ this -> createDirectory ( $ path ) ; $ this -> putContentInFile ( $ file , $ stub ) ; return $ this ; } | It creates a new file . If the target path does not exists one will be created . |
41,059 | protected function getPathToTemplates ( $ template = null ) { $ template = Helpers :: getPathWithSlash ( $ template ? : Config :: getDefaultTemplateName ( ) ) ; $ basePath = base_path ( Config :: getTemplatesPath ( ) . $ template ) ; $ path = Helpers :: getPathWithSlash ( $ basePath ) ; if ( ! $ this -> isFileExists ( ... | Gets the path to templates |
41,060 | protected function containsfile ( array $ fields ) { $ filtered = array_filter ( $ fields , function ( $ field ) { return $ field -> isFile ( ) ; } ) ; return ( count ( $ filtered ) > 0 ) ; } | Checks if a given fields array conatins at least one file field |
41,061 | protected function mergeFields ( & $ resource , $ input ) { $ existingNames = Collect ( $ resource -> fields ) -> pluck ( 'name' ) -> all ( ) ; $ fields = FieldTransformer :: fromString ( $ this -> option ( 'fields' ) , 'generic' , $ input -> translationFor ) ; $ mergeFields = 0 ; foreach ( $ fields as $ field ) { if (... | Merges the given file s content to the new fields . |
41,062 | protected function mergeRelations ( & $ resource , $ input ) { $ existingNames = [ ] ; foreach ( $ resource -> relations as $ relation ) { $ existingNames [ ] = $ relation -> getName ( ) ; } $ mergeRelations = 0 ; foreach ( $ input -> relations as $ relation ) { $ newRelation = ForeignRelationship :: fromString ( $ rel... | Merges the relation to the existing resources . |
41,063 | protected function mergeIndexes ( & $ resource , $ input ) { $ existingNames = [ ] ; foreach ( $ resource -> indexes as $ index ) { $ existingNames [ ] = $ index -> getName ( ) ; } $ mergeIndexes = 0 ; foreach ( $ input -> indexes as $ index ) { $ newIndex = Index :: fromString ( $ index ) ; if ( ! empty ( $ newIndex -... | Merges the indexes to the existing resources . |
41,064 | public function handle ( ) { $ input = $ this -> getCommandInput ( ) ; $ resource = Resource :: fromFile ( $ input -> resourceFile , $ input -> languageFileName ) ; $ destenationFile = $ this -> getDestenationFile ( $ input -> modelName , $ input -> modelDirectory ) ; if ( $ this -> hasErrors ( $ resource , $ destenati... | Builds the model class with the given name . |
41,065 | protected function getDestenationFile ( $ name , $ path ) { if ( ! empty ( $ path ) ) { $ path = Helpers :: getPathWithSlash ( ucfirst ( $ path ) ) ; } return app_path ( Config :: getModelsPath ( $ path . $ name . '.php' ) ) ; } | Gets the destenation file to be created . |
41,066 | protected function getNamespace ( $ modelName , $ modelDirectory ) { $ namespace = Helpers :: getAppNamespace ( ) . Config :: getModelsPath ( $ modelDirectory ) ; return rtrim ( Helpers :: convertSlashToBackslash ( $ namespace ) , '\\' ) ; } | Gets the model s namespace . |
41,067 | protected function getPrimaryKeyName ( Field $ primaryField = null , $ primaryKey = 'id' ) { return ! is_null ( $ primaryField ) ? $ primaryField -> name : $ primaryKey ; } | Gets the correct primary key name . |
41,068 | protected function upsertDeletedAt ( array $ fields ) { foreach ( $ fields as $ field ) { if ( $ field -> isAutoManagedOnDelete ( ) ) { return $ fields ; } } $ fields [ ] = $ this -> getNewDeletedAtField ( ) ; return $ fields ; } | If a given fields collection does not contain a field called deleted_at one will be created . |
41,069 | protected function getNewDeletedAtField ( ) { $ field = current ( FieldTransformer :: fromString ( 'deleted_at' ) ) ; $ field -> isDate = true ; $ field -> dataType = 'datetime' ; $ field -> dateFormat = Config :: getDateTimeFormat ( ) ; return $ field ; } | Gets a new field called deleted_at |
41,070 | protected function getFillables ( $ stub , array $ fields ) { $ fillables = [ ] ; $ indentCount = $ this -> getIndent ( $ stub , $ this -> getTemplateVariable ( 'fillable' ) ) ; $ indent = $ this -> Indent ( $ indentCount - $ this -> backspaceCount ) ; foreach ( $ fields as $ field ) { if ( $ field -> isOnFormView ) { ... | Gets the formatted fillable line . |
41,071 | protected function getFillablesFromString ( $ stub , $ fillablesString ) { $ columns = Helpers :: removeEmptyItems ( explode ( ',' , $ fillablesString ) , function ( $ column ) { return trim ( Helpers :: removeNonEnglishChars ( $ column ) ) ; } ) ; $ fillables = [ ] ; $ indentCount = $ this -> getIndent ( $ stub , $ th... | Gets the fillable string from a given raw string . |
41,072 | protected function getDateFields ( $ stub , array $ fields ) { $ dates = [ ] ; $ indentCount = $ this -> getIndent ( $ stub , $ this -> getTemplateVariable ( 'dates' ) ) ; $ indent = $ this -> Indent ( $ indentCount - $ this -> backspaceCount ) ; foreach ( $ fields as $ field ) { if ( $ field -> isDate ) { $ dates [ ] ... | Gets the date fields string from a given fields array . |
41,073 | protected function getCasts ( $ stub , array $ fields ) { $ casts = [ ] ; $ indentCount = $ this -> getIndent ( $ stub , $ this -> getTemplateVariable ( 'casts' ) ) ; $ indent = $ this -> Indent ( $ indentCount - $ this -> backspaceCount ) ; foreach ( $ fields as $ field ) { if ( $ field -> isCastable ( ) ) { $ casts [... | Gets the castable fields in a string from a given fields array . |
41,074 | protected function makeArrayString ( array $ names , $ index = 0 ) { $ string = implode ( ',' . PHP_EOL , $ names ) ; if ( ! empty ( $ string ) ) { return sprintf ( '[%s%s%s%s]' , PHP_EOL , $ string , PHP_EOL , $ this -> indent ( $ index ) ) ; } return '[]' ; } | Gets array ready string |
41,075 | protected function getRelationMethods ( array $ relations , array $ fields ) { $ methods = [ ] ; foreach ( $ fields as $ field ) { if ( $ field -> hasForeignRelation ( ) ) { $ relation = $ field -> getForeignRelation ( ) ; $ methods [ $ relation -> name ] = $ this -> getRelationshipMethod ( $ relation ) ; } } foreach (... | Gets the relations methods . |
41,076 | protected function getAccessors ( array $ fields = null ) { $ accessors = [ ] ; foreach ( $ fields as $ field ) { if ( $ field -> isMultipleAnswers ( ) ) { $ content = $ this -> getStubContent ( 'model-accessor-multiple-answers' ) ; $ accessors [ ] = $ this -> getAccessor ( $ field , $ content ) ; } if ( $ field -> isD... | Gets accessors for each field that accepts multiple answers . |
41,077 | protected function getMutators ( array $ fields = null ) { $ mutators = [ ] ; foreach ( $ fields as $ field ) { if ( $ field -> isAutoManaged ( ) ) { continue ; } if ( $ field -> isMultipleAnswers ( ) ) { $ content = $ this -> getStubContent ( 'model-mutator-multiple-answers' ) ; $ this -> replaceFieldName ( $ content ... | Gets mutators for each field that accepts multiple answers . |
41,078 | protected function getMutator ( Field $ field , $ content ) { $ stub = $ this -> getStubContent ( 'model-mutator' ) ; $ this -> replaceFieldName ( $ stub , $ field -> name ) -> replaceFieldContent ( $ stub , $ content ) ; return $ stub ; } | Gets mutator for a given field . |
41,079 | protected function getRelationshipMethod ( ForeignRelationship $ relation ) { $ stub = $ this -> getStubContent ( 'model-relation' ) ; $ this -> replaceRelationName ( $ stub , $ relation -> name ) -> replaceRelationType ( $ stub , $ relation -> getType ( ) ) -> replaceRelationParams ( $ stub , $ this -> turnRelationArg... | Creates the code for a relationship . |
41,080 | protected function replaceFieldName ( & $ stub , $ name ) { $ stub = $ this -> strReplace ( 'field_name' , $ name , $ stub ) ; $ stub = $ this -> strReplace ( 'field_name_cap' , ucwords ( camel_case ( $ name ) ) , $ stub ) ; return $ this ; } | Replaces the field name for the given stub . |
41,081 | protected function replaceSoftDelete ( & $ stub , $ shouldUseSoftDelete ) { if ( $ shouldUseSoftDelete ) { $ stub = $ this -> strReplace ( 'use_soft_delete' , PHP_EOL . 'use Illuminate\Database\Eloquent\SoftDeletes;' . PHP_EOL , $ stub ) ; $ stub = $ this -> strReplace ( 'use_soft_delete_trait' , PHP_EOL . ' use Sof... | Replaces useSoftDelete and useSoftDeleteTrait for the given stub . |
41,082 | public function optimize ( ) { $ mappers = $ this -> mappers ; $ this -> assignPrimaryKey ( $ mappers ) -> assignPrimaryTitle ( $ mappers ) ; foreach ( $ mappers as $ mapper ) { $ optimizer = new FieldOptimizer ( $ mapper -> field , $ mapper -> meta ) ; $ this -> addField ( $ optimizer -> optimize ( ) -> getField ( ) )... | Optemizes the fields . |
41,083 | protected function assignPrimaryKey ( array & $ mappers ) { $ foundPrimary = false ; foreach ( $ mappers as $ mapper ) { if ( $ foundPrimary ) { $ mapper -> field -> isPrimary = false ; $ mapper -> field -> isAutoIncrement = false ; continue ; } if ( $ mapper -> field -> isPrimary ( ) ) { $ mapper -> field -> isPrimary... | Assigned and fix the primary key field of the given collection . |
41,084 | protected function assignPrimaryTitle ( array & $ mappers ) { $ fieldsWithHeader = array_filter ( $ mappers , function ( $ mapper ) { return $ mapper -> field -> isHeader ; } ) ; if ( count ( $ fieldsWithHeader ) == 0 ) { $ found = false ; foreach ( $ mappers as $ mapper ) { if ( $ found ) { $ mapper -> field -> isHead... | given a mappers collection it ll update the the field by making one as primary title |
41,085 | protected function isPrimaryHeader ( Field $ field ) { return $ field -> isHeader || Helpers :: strIs ( Config :: getHeadersPatterns ( ) , $ field -> name ) ; } | It checks if a given field is a primary or not . |
41,086 | public function getValue ( $ range ) { $ range = $ range == 'min' ? $ range : 'max' ; if ( is_null ( $ this -> { $ range } ) ) { $ this -> { $ range } = $ this -> getFirst ( $ range ) ; } return $ this -> { $ range } ; } | Gets the numeric min value . |
41,087 | public function getSizeValue ( ) { if ( is_null ( $ this -> size ) ) { $ this -> size = $ this -> getFirst ( 'size' ) ; } return $ this -> size ; } | Gets the size value |
41,088 | protected function getSetValue ( $ name , $ callback = null ) { if ( property_exists ( $ this , $ name ) ) { return $ this -> isRuleExists ( $ name ) ; } if ( is_null ( $ this -> { $ name } ) ) { $ this -> { $ name } = $ this -> isRuleExists ( $ name ) ; } return $ this -> { $ name } ; } | Sets a protected value and it gets its value |
41,089 | public function isConditionalRequired ( ) { if ( is_null ( $ this -> conditionalRequired ) ) { $ this -> conditionalRequired = $ this -> startsWith ( 'required_' ) ; } return $ this -> conditionalRequired ; } | Checks if the rules has a conditional required |
41,090 | public function isNullable ( ) { if ( is_null ( $ this -> nullable ) ) { $ this -> nullable = $ this -> isRuleExists ( 'nullable' ) ; } return $ this -> nullable ; } | Checks if the rules is nullable |
41,091 | public function isInteger ( ) { if ( is_null ( $ this -> integer ) ) { $ this -> integer = $ this -> isRuleExists ( 'integer' ) ; } return $ this -> integer ; } | Checks if the rules is interger . |
41,092 | protected function getFirst ( $ key ) { foreach ( $ this -> rules as $ rule ) { if ( substr ( $ rule , 0 , strlen ( $ key ) ) == $ key ) { $ params = explode ( ':' , $ rule , 2 ) ; if ( isset ( $ params [ 1 ] ) ) { return intval ( $ params [ 1 ] ) ; } } } return '' ; } | Gets the first found key in the rules |
41,093 | protected function startsWith ( $ key ) { foreach ( $ this -> rules as $ rule ) { if ( starts_with ( $ rule , $ key ) ) { return true ; } } return false ; } | Checks if any rule starts with a given key |
41,094 | public function addLines ( array $ lines , $ locale , $ namespace = '*' ) { foreach ( $ lines as $ key => $ value ) { list ( $ group , $ item ) = explode ( '.' , $ key , 2 ) ; Arr :: set ( $ this -> loaded , "$namespace.$group.$locale.$item" , $ value ) ; } } | Add translation lines to the given locale . |
41,095 | public static function getTranslator ( ) { $ translator = app ( 'translator' ) ; app ( ) -> singleton ( 'crestapps_translator' , function ( $ app ) use ( $ translator ) { $ trans = new CrestAppsTranslator ( $ translator -> getLoader ( ) , $ translator -> getLocale ( ) ) ; $ trans -> setFallback ( $ translator -> getFal... | Adds a new instance of crestapps_translator to the IoC container |
41,096 | public function setParameters ( $ parameters ) { $ this -> parameters = [ ] ; if ( ! is_array ( $ parameters ) ) { $ parameters = Helpers :: convertStringToArray ( $ parameters , '|' ) ; } foreach ( $ parameters as $ parameter ) { $ this -> parameters [ ] = Helpers :: eliminateDupilcates ( $ parameter , "\\" ) ; } } | Sets the parameters for the relation |
41,097 | public function getField ( ) { if ( empty ( $ this -> field ) ) { $ this -> field = $ this -> guessForeignField ( ) ; } return $ this -> field ; } | Get the foreign field name . |
41,098 | protected function guessForeignField ( ) { $ columns = $ this -> getModelColumns ( ) ; $ names = Config :: getHeadersPatterns ( ) ; foreach ( $ columns as $ column ) { if ( Helpers :: strIs ( $ names , $ column ) ) { return $ column ; } } $ primary = $ this -> getPrimaryKeyForForeignModel ( ) ; $ idPatterns = Config ::... | Guesses the name of the foreign key . |
41,099 | public function getForeignModel ( ) { $ model = $ this -> getFullForeignModel ( ) ; if ( $ this -> isModel ( $ model ) ) { return class_basename ( $ model ) ; } $ position = strrpos ( $ model , '\\' ) ; if ( $ position !== false ) { return substr ( $ model , $ position + 1 ) ; } return '' ; } | Gets the foreign model name . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.