idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
40,900 | public function getSelectMonthHtmlField ( Field $ field ) { $ stub = $ this -> getStubContent ( 'form-month-field.blade' , $ this -> template ) ; $ this -> replaceFieldName ( $ stub , $ field -> name ) -> replaceCssClass ( $ stub , $ field -> cssClass ) -> replaceSelectedValue ( $ stub , $ this -> getSelectedValue ( $ ... | Gets a selectmonth element for a given field . |
40,901 | protected function getMax ( ) { $ params = array_filter ( func_get_args ( ) ? : [ ] , function ( $ arg ) { return ! is_null ( $ arg ) && $ arg !== "" ; } ) ; return count ( $ params ) > 0 ? max ( $ params ) : null ; } | Gets the gretest value of the given parameters . It ignores null or empty string . |
40,902 | protected function getMin ( ) { $ params = array_filter ( func_get_args ( ) ? : [ ] , function ( $ arg ) { return ! is_null ( $ arg ) && $ arg !== "" ; } ) ; return count ( $ params ) > 0 ? min ( $ params ) : null ; } | Gets the smallest value of the given parameters . It ignores null or empty string . |
40,903 | protected function wrapField ( & $ fieldStub , Field $ field , $ standardLabel = true , $ required = '' ) { $ stub = $ this -> getStubContent ( 'form-input-wrapper.blade' , $ this -> template ) ; $ this -> replaceFieldName ( $ stub , $ field -> name ) -> replaceCssClass ( $ stub , $ field -> cssClass ) -> replaceFieldL... | Wraps a field with a wrapper template |
40,904 | protected function getLabelFromField ( Field $ field = null ) { if ( empty ( $ field ) ) { return $ this -> getStubContent ( 'form-nolabel-field.blade' , $ this -> template ) ; } return $ this -> getLabelElement ( $ field -> name , $ field -> getLabel ( ) ) ; } | Creates html label from a given field |
40,905 | protected function getLabelElement ( $ name , Label $ label ) { $ labelStub = $ this -> getStubContent ( 'form-label-field.blade' , $ this -> template ) ; $ this -> replaceFieldName ( $ labelStub , $ name ) -> replaceFieldTitle ( $ labelStub , $ this -> getTitle ( $ label ) ) ; return $ labelStub ; } | Creates html label . |
40,906 | protected function getNewHelper ( Field $ field ) { $ stub = $ this -> getStubContent ( 'form-helper-field.blade' , $ this -> template ) ; $ this -> replaceFieldName ( $ stub , $ field -> name ) ; return $ stub ; } | Creates helper block |
40,907 | protected function getTitle ( Label $ label , $ raw = false ) { if ( ! $ label -> isPlain ) { return $ this -> getTranslatedTitle ( $ label , $ raw ) ; } return $ this -> getPlainTitle ( $ label , $ raw ) ; } | Gets title to display from a given label . |
40,908 | protected function replaceFieldMinLengthName ( & $ stub , $ minLength ) { $ stub = $ this -> strReplace ( 'min_length' , $ this -> getFieldMinLengthName ( $ minLength ) , $ stub ) ; return $ this ; } | Replace the minLength fo the given stub . |
40,909 | protected function replaceFieldMaxLengthName ( & $ stub , $ maxLength ) { $ stub = $ this -> strReplace ( 'max_length' , $ this -> getFieldMaxLengthName ( $ maxLength ) , $ stub ) ; return $ this ; } | Replace the maxLength fo the given stub . |
40,910 | protected function replaceFieldRequired ( & $ stub , $ required ) { $ stub = $ this -> strReplace ( 'required_field' , $ this -> getFieldRequired ( $ required ) , $ stub ) ; return $ this ; } | Replace the requiredField fo the given stub . |
40,911 | protected function replaceFieldMultiple ( & $ stub , $ isMultiple ) { $ stub = $ this -> strReplace ( 'field_multiple' , $ this -> getFieldMultiple ( $ isMultiple ) , $ stub ) ; return $ this ; } | It replaces the fieldMultiple template |
40,912 | public function getTranslatedLabels ( array $ languages ) { $ labels = [ ] ; foreach ( $ languages as $ language ) { foreach ( Config :: getCustomModelTemplates ( ) as $ key => $ properties ) { $ label = $ this -> makeModelLabel ( $ key , $ properties , false , $ language ) ; $ labels [ $ language ] [ ] = $ label ; } }... | Gets translatable labels for the given languages if any |
40,913 | public function getLabels ( ) { $ languages = array_keys ( Helpers :: getLanguageItems ( $ this -> fields ) ) ; if ( count ( $ languages ) > 0 ) { return $ this -> getTranslatedLabels ( $ languages ) ; } return $ this -> getPlainLabels ( ) ; } | Gets translatable labels for the given languages if any otherwise get plain labels |
40,914 | protected function getPlainLabels ( ) { $ labels = [ ] ; foreach ( Config :: getCustomModelTemplates ( ) as $ key => $ properties ) { $ label = $ this -> makeModelLabel ( $ key , $ properties , true , $ this -> defaultLang ) ; $ labels [ $ this -> defaultLang ] [ ] = $ label ; } return $ labels ; } | Get plain labels . |
40,915 | protected function makeModelLabel ( $ key , array $ properties , $ isPlain , $ lang ) { $ text = $ properties [ 'text' ] ; $ this -> replaceModelName ( $ text , $ this -> modelName ) ; $ localeKey = sprintf ( '%s.%s' , $ this -> localeGroup , $ key ) ; $ label = new Label ( $ text , $ localeKey , $ isPlain , $ lang , $... | Makes a label from a model |
40,916 | protected function getMappingFile ( ) { $ name = trim ( $ this -> option ( 'mapping-filename' ) ) ? : Config :: getDefaultMapperFileName ( ) ; return base_path ( Config :: getResourceFilePath ( $ name ) ) ; } | Gets the full name of the mapping file . |
40,917 | protected function getDestenationPath ( $ path ) { if ( ! empty ( $ path ) ) { $ path = Helpers :: getPathWithSlash ( $ path ) ; } return Config :: getViewsPath ( ) . $ path ; } | Gets the destenation path . |
40,918 | protected function getCurrentResource ( $ resourceFile ) { $ resource = Resource :: fromFile ( $ resourceFile , 'migration' ) ; if ( ! $ resource -> hasFields ( ) && ! $ resource -> hasIndexes ( ) ) { throw new Exception ( 'You must provide at least one field or index to generate the migration' ) ; } return $ resource ... | Gets resource using current fields file |
40,919 | protected function getMigrationTrackerCapsule ( MigrationInput $ input ) { return MigrationTrackerCapsule :: get ( $ this -> tableName , $ input -> modelName , $ input -> resourceFile ) ; } | Gets a new migration capsule |
40,920 | protected function makeCreateMigration ( MigrationInput $ input , MigrationCapsule $ migration ) { $ stub = $ this -> getStubContent ( 'migration' , $ input -> template ) ; $ blueprint = $ this -> getCreateTableBlueprint ( $ migration -> resource , $ input ) ; $ this -> replaceSchemaUp ( $ stub , $ this -> getSchemaUpC... | Make a create migration |
40,921 | protected function makeAlterMigration ( MigrationInput $ input , MigrationCapsule $ migration , MigrationChangeCapsule $ changeCapsule ) { $ stub = $ this -> getStubContent ( 'migration' , $ input -> template ) ; $ blueprint = $ this -> getSchemaUpAlterBlueprint ( $ input , $ changeCapsule ) ; $ downBlueprint = $ this ... | Make an alter migration |
40,922 | protected function getColumnsUsedInMigration ( Resource $ resource , MigrationInput $ input ) { $ columns = collect ( $ resource -> fields ) -> pluck ( 'name' ) -> toArray ( ) ; if ( ! $ input -> withoutTimestamps ) { $ columns [ ] = 'created_at' ; $ columns [ ] = 'updated_at' ; } if ( $ input -> withSoftDelete ) { $ c... | Gets a list of all column that are used in the given migration |
40,923 | protected function addForeignConstraints ( & $ properties , array $ constraints ) { foreach ( $ constraints as $ constraint ) { $ this -> addForeignConstraint ( $ properties , $ constraint ) -> addReferencesConstraint ( $ properties , $ constraint ) -> addOnConstraint ( $ properties , $ constraint ) -> addOnDeleteConst... | Adds foreign key constraint to a given properties . |
40,924 | protected function getConstraintsFromfields ( array $ fields ) { $ constraints = [ ] ; foreach ( $ fields as $ field ) { if ( $ field -> hasForeignConstraint ( ) ) { $ constraints [ ] = $ field -> getForeignConstraint ( ) ; } } return $ constraints ; } | Gets Foreign contstrains from given fields . |
40,925 | protected function addForeignConstraint ( & $ properties , ForeignConstraint $ constraint ) { $ properties .= PHP_EOL . sprintf ( "%s('%s')" , $ this -> getPropertyBase ( 'foreign' ) , $ constraint -> column ) ; return $ this ; } | Adds foreign eloquent method to a given properties . |
40,926 | protected function addReferencesConstraint ( & $ properties , ForeignConstraint $ constraint ) { $ properties .= $ this -> getPropertyBaseSpace ( 18 , true ) . sprintf ( "->references('%s')" , $ constraint -> references ) ; return $ this ; } | Adds references eloquent method to a given properties . |
40,927 | protected function addOnConstraint ( & $ properties , ForeignConstraint $ constraint ) { $ properties .= $ this -> getPropertyBaseSpace ( 18 , true ) . sprintf ( "->on('%s')" , $ constraint -> on ) ; return $ this ; } | Adds on eloquent method to a given properties . |
40,928 | protected function addOnDeleteConstraint ( & $ properties , ForeignConstraint $ constraint ) { if ( $ constraint -> hasDeleteAction ( ) ) { $ properties .= $ this -> getPropertyBaseSpace ( 18 , true ) . sprintf ( "->onDelete('%s')" , $ constraint -> onDelete ) ; } return $ this ; } | Adds onDelete eloquent method to a given properties . |
40,929 | protected function addOnUpdateConstraint ( & $ properties , ForeignConstraint $ constraint ) { if ( $ constraint -> hasUpdateAction ( ) ) { $ properties .= $ this -> getPropertyBaseSpace ( 18 , true ) . sprintf ( "->onUpdate('%s')" , $ constraint -> onUpdate ) ; } return $ this ; } | Adds onUpdate eloquent method to a given properties . |
40,930 | protected function addFieldProperties ( & $ properties , array $ fields , $ withoutTimestamps , $ withSoftDelete ) { $ primaryField = $ this -> getPrimaryField ( $ fields ) ; foreach ( $ fields as $ field ) { if ( $ field instanceof Field && $ field != $ primaryField ) { if ( ! $ withoutTimestamps && $ field -> isAutoM... | Adds the standard field method . |
40,931 | protected function addFieldType ( & $ property , Field $ field ) { $ params = $ this -> getMethodParamerters ( $ field ) ; $ property .= sprintf ( "%s('%s'%s)" , $ this -> getPropertyBase ( $ field -> getEloquentDataMethod ( ) ) , $ field -> name , $ params ) ; return $ this ; } | Adds a field type to the property |
40,932 | protected function getMethodParamerters ( Field $ field ) { $ params = count ( $ field -> methodParams ) == 0 ? '' : ', ' . implode ( ',' , $ field -> methodParams ) ; if ( $ field -> getEloquentDataMethod ( ) == 'enum' ) { $ params = ', ' . $ this -> getEnumParams ( $ field ) ; } return $ params ; } | Constructs the second parameter to the type method |
40,933 | protected function getEnumParams ( Field $ field ) { if ( $ field -> getEloquentDataMethod ( ) != 'enum' ) { throw new Exception ( 'The field type is not enum! Cannot create an enum column with no options.' ) ; } $ labels = array_filter ( $ field -> getOptionsByLang ( ) , function ( $ option ) use ( $ field ) { return ... | Constructs the second parameter to the enum type method |
40,934 | protected function getLabelValues ( array $ labels ) { $ values = [ ] ; foreach ( $ labels as $ label ) { if ( $ label instanceof Label ) { $ values [ ] = $ label -> value ; } } return $ values ; } | It gets label s value for each label in the given labels |
40,935 | protected function replaceConnectionName ( & $ stub , $ name ) { $ connectionLine = ! empty ( $ name ) ? sprintf ( "connection('%s')->" , $ name ) : '' ; return $ this -> replaceTemplate ( 'connection_name' , $ connectionLine , $ stub ) ; } | Replaces the connection s name for the given stub . |
40,936 | protected function addFieldDefaultValue ( & $ property , Field $ field ) { if ( ! is_null ( $ field -> dataValue ) && ! $ field -> nullable ) { $ property .= sprintf ( "->default('%s')" , $ field -> dataValue ) ; } return $ this ; } | Adds the field s default value to the given property . |
40,937 | protected function addDropColumn ( & $ property , $ name ) { if ( is_array ( $ name ) ) { $ property .= sprintf ( '%s([%s])' , $ this -> getPropertyBase ( 'dropColumn' ) , implode ( ',' , Helpers :: wrapItems ( $ name ) ) ) ; } else { $ property .= sprintf ( "%s('%s')" , $ this -> getPropertyBase ( 'dropColumn' ) , $ n... | Adds the field s dropColumn method call to the given property . |
40,938 | protected function addRenameColumn ( & $ property , $ from , $ to ) { $ property .= sprintf ( "%s('%s', '%s')" , $ this -> getPropertyBase ( 'renameColumn' ) , $ from , $ to ) ; return $ this ; } | Adds the field s renameColumn method call to the given property . |
40,939 | protected function addFieldIndex ( & $ property , Field $ field ) { if ( $ field -> isIndex && ! $ field -> isUnique ) { $ property .= '->index()' ; } return $ this ; } | Adds the field s index value to the given property . |
40,940 | protected function addIndex ( & $ property , Index $ index ) { $ property .= sprintf ( "('%s')" , $ this -> getPropertyBase ( $ index -> getType ) , $ index -> name ) ; return $ this -> addFieldPropertyClousure ( $ property ) ; } | Adds an index |
40,941 | protected function dropIndex ( & $ property , Index $ index ) { $ property .= sprintf ( "('%s')" , $ this -> getPropertyBase ( 'drop' . ucfirst ( $ index -> getType ) ) , $ index -> name ) ; return $ this -> addFieldPropertyClousure ( $ property ) ; } | drop an index |
40,942 | protected function addFieldComment ( & $ property , Field $ field ) { if ( ! empty ( $ field -> comment ) ) { $ property .= sprintf ( "->comment('%s')" , $ field -> comment ) ; } return $ this ; } | Adds the field s comment value to the given property . |
40,943 | protected function addEngineName ( & $ property , $ name ) { if ( ! empty ( $ name ) ) { $ property .= sprintf ( "%s = '%s'" , $ this -> getPropertyBase ( 'engine' ) , $ name ) ; $ this -> addFieldPropertyClousure ( $ property ) ; } return $ this ; } | Adds the table s engine type to the given property . |
40,944 | protected function addPrimaryField ( & $ property , Field $ field = null ) { if ( ! is_null ( $ field ) ) { $ eloquentMethodName = $ this -> getPrimaryMethodName ( $ field -> getEloquentDataMethod ( ) ) ; $ property .= sprintf ( "%s('%s')" , $ this -> getPropertyBase ( $ eloquentMethodName ) , $ field -> name ) ; $ thi... | Adds the table s primary column to the given property . |
40,945 | protected function addTimestamps ( & $ property , $ without = false ) { if ( ! $ without ) { $ property .= sprintf ( "%s()" , $ this -> getPropertyBase ( 'timestamps' ) ) ; $ this -> addFieldPropertyClousure ( $ property ) ; } return $ this ; } | Adds updated_at and created_at columns to a given propery . |
40,946 | protected function addSoftDelete ( & $ property , $ withSoftDelete = true ) { if ( $ withSoftDelete ) { $ property .= sprintf ( "%s()" , $ this -> getPropertyBase ( 'softDeletes' ) ) ; $ this -> addFieldPropertyClousure ( $ property ) ; } return $ this ; } | Adds delete_at columns to a given propery . |
40,947 | protected function getPrimaryMethodName ( $ type ) { $ type = strtolower ( $ type ) ; $ methodName = 'primary' ; if ( in_array ( $ type , [ 'int' , 'integer' ] ) ) { $ methodName = 'increments' ; } elseif ( in_array ( $ type , [ 'bigint' , 'biginteger' ] ) ) { $ methodName = 'bigIncrements' ; } elseif ( in_array ( $ ty... | Gets the correct eloquent increment method from the given type . |
40,948 | protected function getStatusFor ( array $ ran ) { return Collection :: make ( $ this -> getAllMigrationFiles ( ) ) -> map ( function ( $ migration ) use ( $ ran ) { $ migrationName = $ this -> migrator -> getMigrationName ( $ migration ) ; return in_array ( $ migrationName , $ ran ) ? [ '<info>Y</info>' , $ migrationNa... | Get the status for the given ran migrations . |
40,949 | public static function get ( array $ properties ) { if ( ! array_key_exists ( 'columns' , $ properties ) ) { throw new Exception ( 'An index requires at least one column.' ) ; } $ index = new Index ( ) ; foreach ( ( array ) $ properties [ 'columns' ] as $ column ) { $ index -> addColumn ( $ column ) ; } if ( array_key_... | Gets an index from an array . |
40,950 | public static function fromString ( $ rawIndex ) { $ parts = explode ( ';' , $ rawIndex ) ; foreach ( $ parts as $ part ) { if ( ! str_contains ( $ part , ':' ) ) { continue ; } list ( $ key , $ value ) = explode ( ':' , $ part ) ; $ collection [ $ key ] = $ value ; } return self :: get ( $ collection ) ; } | Gets an index from a raw string . |
40,951 | protected function getFieldPlaceHolder ( Label $ placeholder = null ) { if ( is_null ( $ placeholder ) ) { return '' ; } return empty ( $ placeholder ) ? '' : sprintf ( ' placeholder="%s"' , $ this -> getTitle ( $ placeholder , true ) ) ; } | Get the placeholder attribute . |
40,952 | protected function getFieldPlaceHolderForMenu ( Label $ placeholder = null , $ name = '' ) { if ( is_null ( $ placeholder ) ) { return '' ; } return sprintf ( '<option value="" style="display: none;" {{ %s == \'\' ? \'selected\' : \'\' }} disabled selected>%s</option>' , $ this -> getRawOptionValue ( $ name , '' ) , $ ... | Get the placeholder attribute for a menu . |
40,953 | protected function getDefaultValueAccessor ( $ modelVariable , $ property , $ value ) { if ( Helpers :: isNewerThanOrEqualTo ( '5.5' ) ) { $ template = sprintf ( 'optional($%s)->%s' , $ modelVariable , $ property ) ; if ( is_null ( $ value ) || in_array ( $ value , [ 'null' , '[]' ] ) ) { return $ template ; } return $... | Gets the best value accessor for the view |
40,954 | public static function fromJson ( $ json , $ localeGroupm , array $ languages = [ ] ) { if ( empty ( $ json ) || ( $ fields = json_decode ( $ json , true ) ) === null ) { throw new Exception ( "The provided string is not a valid json." ) ; } $ transformer = new self ( $ fields , $ localeGroup , $ languages ) ; return $... | It transfres a gining string to a collection of field |
40,955 | protected function setLabels ( & $ properties ) { $ label = $ properties [ 'name' ] ; if ( Helpers :: isKeyExists ( $ properties , 'labels' ) ) { $ label = $ properties [ 'labels' ] ; } $ properties [ 'labels' ] = $ this -> getLabels ( $ label , $ properties [ 'name' ] ) ; return $ this ; } | Sets the labels property |
40,956 | protected function setPlaceholder ( & $ properties ) { if ( ! Helpers :: isKeyExists ( $ properties , 'placeholder' ) ) { $ properties [ 'placeholder' ] = $ this -> getPlaceholders ( $ properties [ 'name' ] , $ this -> getHtmlType ( $ properties ) ) ; } return $ this ; } | Sets the placeholder property |
40,957 | public function presetProperties ( array & $ properties ) { $ definitions = Config :: getCommonDefinitions ( ) ; foreach ( $ definitions as $ definition ) { $ patterns = $ this -> getArrayByKey ( $ definition , 'match' ) ; if ( Helpers :: strIs ( $ patterns , $ properties [ 'name' ] ) ) { $ settings = $ this -> getArra... | Get the properties after applying the predefined keys . |
40,958 | protected function getOptions ( array $ options ) { $ labels = [ ] ; if ( $ this -> hasLanguages ( ) ) { foreach ( $ this -> languages as $ language ) { foreach ( $ options as $ key => $ option ) { $ labels [ $ language ] [ $ key ] = Helpers :: convertNameToLabel ( $ option ) ; } } } else { foreach ( $ options as $ key... | Gets options from a given array of options |
40,959 | protected function getControllerName ( $ name , $ namespace ) { if ( empty ( $ namespace ) ) { return $ name ; } $ path = Helpers :: postFixWith ( $ namespace , '\\' ) ; return Helpers :: convertSlashToBackslash ( $ path . $ name ) ; } | Gets the correct controller name with the namespace . |
40,960 | protected function processRoutesGroup ( & $ stub , $ prefix , $ namespace ) { $ prefix = trim ( $ prefix ) ; if ( ! empty ( $ prefix ) || ! empty ( $ namespace ) ) { $ groupStub = $ this -> getStubContent ( 'routes-group' ) ; $ this -> replacePrefix ( $ groupStub , $ this -> getGroupPrefix ( $ prefix ) ) -> replaceRout... | Groups the routes with a prefix and namespace if prefix or namespace is provided . |
40,961 | protected function isRouteNameExists ( $ name ) { $ existingRoutes = Route :: getRoutes ( ) ; foreach ( $ existingRoutes as $ existingRoute ) { if ( $ existingRoute -> getName ( ) == $ name ) { return true ; } } return false ; } | Checks if a route name is already registred . |
40,962 | protected function createVirtualMigration ( Resource $ resource , $ destenationFile , $ tableName ) { $ tracker = new MigrationHistoryTracker ( ) ; $ capsule = $ tracker -> get ( $ tableName ) ; if ( ! is_null ( $ capsule ) ) { $ tracker -> forget ( $ tableName ) ; } $ capsule = MigrationTrackerCapsule :: get ( $ table... | Creates a virtual migration in the migration tracker |
40,963 | protected function getParser ( ) { $ driver = strtolower ( DB :: getDriverName ( ) ) ; if ( ! in_array ( $ driver , $ this -> drivers ) ) { throw new Exception ( 'The database driver user is not supported!' ) ; } $ class = sprintf ( 'CrestApps\CodeGenerator\DatabaseParsers\%sParser' , ucfirst ( $ driver ) ) ; return ne... | Gets the fields collection after from using the connection s driver . |
40,964 | protected function getNewFilename ( ) { $ filename = trim ( $ this -> option ( 'resource-filename' ) ) ? : Helpers :: makeJsonFileName ( $ this -> getModelName ( ) ) ; return str_finish ( $ filename , '.json' ) ; } | Gets the destenation filename . |
40,965 | public function all ( ) { $ rawCapsules = json_decode ( $ this -> read ( ) , true ) ; $ capsules = [ ] ; foreach ( $ rawCapsules as $ rawCapsule ) { $ capsules [ ] = new MigrationTrackerCapsule ( $ rawCapsule ) ; } return $ capsules ; } | Gets all the migration capsules from the file . |
40,966 | public function get ( $ tableName ) { $ capsules = $ this -> all ( ) ; foreach ( $ capsules as $ capsule ) { if ( $ capsule -> tableName == $ tableName ) { return $ capsule ; } } return null ; } | Gets a migration capsule from the file if any |
40,967 | public function has ( $ tableName ) { $ capsules = $ this -> all ( ) ; foreach ( $ capsules as $ capsule ) { if ( $ capsule -> tableName == $ tableName ) { return true ; } } return false ; } | Checks if a migration tracker exists for a given datatable |
40,968 | public function add ( MigrationTrackerCapsule $ capsule , MigrationCapsule $ migration = null ) { $ capsules = $ this -> all ( ) ; if ( ! is_null ( $ migration ) ) { $ capsule -> addMigration ( $ migration ) ; } $ capsules [ ] = $ capsule ; $ this -> write ( $ capsules ) ; return $ capsules ; } | Adds properties to the migration tracker |
40,969 | protected function write ( array $ capsules ) { $ converted = array_map ( function ( $ capsule ) { return $ capsule -> toArray ( ) ; } , $ capsules ) ; File :: put ( $ this -> capsuleFile , Helpers :: prettifyJson ( $ converted ) ) ; } | Writes array of capsules to the file . |
40,970 | public function forget ( $ tableName ) { $ capsules = $ this -> all ( ) ; $ keep = [ ] ; foreach ( $ capsules as $ capsule ) { if ( $ capsule -> tableName == $ tableName ) { $ capsule -> forgetAllMigrations ( ) ; continue ; } $ keep [ ] = $ capsule ; } $ this -> write ( $ keep ) ; return $ keep ; } | Removeds a migration entry from the file given the table name . |
40,971 | public function updateMigration ( $ tableName , MigrationCapsule $ migrationCapsule ) { $ capsules = $ this -> all ( ) ; foreach ( $ capsules as $ capsule ) { if ( $ capsule -> tableName == $ tableName ) { $ capsule -> updateMigration ( $ migrationCapsule ) ; } } $ this -> write ( $ capsules ) ; return $ this ; } | Updates the content of the migration . |
40,972 | public function forgetMigration ( $ tableName , $ name ) { $ capsules = $ this -> all ( ) ; $ keep = [ ] ; foreach ( $ capsules as $ capsule ) { if ( $ capsule -> tableName == $ tableName ) { $ key = $ capsule -> getMigrationIndex ( $ name ) ; $ capsule -> forgetMigration ( $ key ) ; } $ keep [ ] = $ capsule ; } $ this... | Remove a migration entry from the file given the table name and migration name . |
40,973 | public static function compare ( Field $ fieldA , Field $ fieldB ) { $ change = new FieldMigrationChange ( ) ; $ change -> fromField = $ fieldA ; $ change -> toField = $ fieldB ; return $ change ; } | Get the migration change after comparing two given fields |
40,974 | protected function getConstraint ( $ foreign ) { foreach ( $ this -> getConstraints ( ) as $ constraint ) { if ( $ constraint -> foreign == $ foreign ) { return ( object ) $ constraint ; } } return null ; } | Gets foreign key constraint info for a given column name . |
40,975 | protected function getConstraints ( ) { if ( is_null ( $ this -> constrains ) ) { $ this -> constrains = DB :: select ( 'SELECT r.referenced_table_name AS `references` ,r.CONSTRAINT_NAME AS `name` ,r.UPDATE_RULE AS `onUpdate` ,r.DELETE_RULE AS `on... | Gets foreign key constraints info from the information schema . |
40,976 | protected function getRelations ( ) { $ relations = [ ] ; $ rawRelations = $ this -> getRawRelations ( ) ; foreach ( $ rawRelations as $ rawRelation ) { $ relations [ ] = $ this -> getRealtion ( $ rawRelation -> foreignTable , $ rawRelation -> foreignKey , $ rawRelation -> localKey , $ rawRelation -> selfReferences ) ;... | Get all available relations |
40,977 | protected function getRawRelations ( ) { if ( is_null ( $ this -> relations ) ) { $ this -> relations = DB :: select ( 'SELECT DISTINCT u.referenced_column_name AS `localKey` ,u.column_name AS `foreignKey` ,r.table_name AS `foreignTable` ,CASE WHEN u.TABLE_NA... | Gets the raw relations from the database . |
40,978 | protected function getRealtion ( $ foreignTableName , $ foreignColumn , $ localColumn , $ selfReferences ) { $ modelName = $ this -> getModelName ( $ foreignTableName ) ; $ model = Helpers :: guessModelFullName ( $ modelName , Helpers :: getModelsPath ( ) ) ; $ params = [ $ model , $ foreignColumn , $ localColumn , ] ;... | Get a corresponding relation to a given table name foreign column and local column . |
40,979 | protected function isOneToMany ( $ tableName , $ columnName ) { $ query = $ this -> getRelationTypeQuery ( $ tableName , $ columnName ) ; $ result = DB :: select ( $ query ) ; return isset ( $ result [ 0 ] ) ; } | Checks of the table has one - to - many relations |
40,980 | protected function getIndexes ( ) { $ indexes = [ ] ; $ rawIndexes = $ this -> getRawIndexes ( ) ; foreach ( $ rawIndexes as $ rawIndex ) { $ index = new Index ( $ rawIndex -> name ) ; $ index -> addColumns ( explode ( '|||' , $ rawIndex -> columns ) ) ; $ indexes [ ] = $ index ; } return $ indexes ; } | Get all available indexed |
40,981 | protected function getTransfredFields ( array $ columns ) { $ collection = [ ] ; foreach ( $ columns as $ column ) { $ properties [ 'name' ] = $ column -> COLUMN_NAME ; $ properties [ 'is-nullable' ] = ( $ column -> IS_NULLABLE == 'YES' ) ; $ properties [ 'data-value' ] = $ column -> COLUMN_DEFAULT ; $ properties [ 'da... | Gets the field after transfering it from a given query object . |
40,982 | protected function getPrecision ( $ length , $ dataType , $ columnType ) { if ( in_array ( $ dataType , [ 'decimal' , 'double' , 'float' , 'real' ] ) ) { $ match = [ ] ; preg_match ( '#\((.*?)\)#' , $ columnType , $ match ) ; if ( ! isset ( $ match [ 1 ] ) ) { return null ; } return explode ( ',' , $ match [ 1 ] ) ; } ... | Gets the type params |
40,983 | protected function getDataType ( $ type , $ columnType ) { $ map = Config :: dataTypeMap ( ) ; if ( in_array ( $ columnType , [ 'bit' , 'tinyint(1)' ] ) ) { return 'boolean' ; } if ( ! array_key_exists ( $ type , $ map ) ) { throw new Exception ( "The type " . $ type . " is not mapped in the 'eloquent_type_to_method' k... | Gets the data type for a given field . |
40,984 | protected function getForeignConstraint ( $ name ) { $ raw = $ this -> getConstraint ( $ name ) ; if ( is_null ( $ raw ) ) { return null ; } return new ForeignConstraint ( $ raw -> foreign , $ raw -> references , $ raw -> on , strtolower ( $ raw -> onDelete ) , strtolower ( $ raw -> onUpdate ) , null , $ raw -> selfRef... | Gets the foreign constrain for the given field . |
40,985 | protected function getEnumOptions ( $ type ) { $ match = [ ] ; preg_match ( '#enum\((.*?)\)#' , $ type , $ match ) ; if ( ! isset ( $ match [ 1 ] ) ) { return null ; } $ options = array_map ( function ( $ option ) { return trim ( $ option , "'" ) ; } , explode ( ',' , $ match [ 1 ] ) ) ; $ finals = [ ] ; foreach ( $ op... | Parses out the options from a given type |
40,986 | public function isMigrated ( array $ ran = null ) { if ( is_null ( $ ran ) ) { $ ran = $ this -> getRan ( ) ; } return in_array ( $ this -> name , $ ran ) ; } | Checks if this migrated is migrated or not . |
40,987 | public function getReferencesModel ( ) { if ( empty ( $ this -> referencesModel ) ) { $ this -> referencesModel = $ this -> getModelNamespace ( ucfirst ( $ this -> getForeignModelName ( ) ) ) ; } return $ this -> referencesModel ; } | Get the model that is being referenced . |
40,988 | public function getForeignRelation ( ) { $ params = [ $ this -> getReferencesModel ( ) , $ this -> column , $ this -> on , ] ; $ prefix = $ this -> isSelfReference ( ) ? 'parent_' : '' ; $ relation = new ForeignRelationship ( 'belongsTo' , $ params , $ this -> getForeignModelName ( $ prefix ) ) ; return $ relation ; } | Get a foreign relation . |
40,989 | protected function getModelNamespace ( $ modelName ) { $ path = Helpers :: getAppNamespace ( ) . rtrim ( Config :: getModelsPath ( ) , '\\' ) ; return $ path . '\\' . $ modelName ; } | Get the namecpase of the foreign model . |
40,990 | public function toArray ( ) { return [ 'field' => $ this -> column , 'references' => $ this -> references , 'on' => $ this -> on , 'on-delete' => $ this -> onDelete , 'on-update' => $ this -> onUpdate , 'references-model' => $ this -> getReferencesModel ( ) , 'is-self-reference' => $ this -> isSelfReference ( ) , ] ; } | Gets the constrain in an array format . |
40,991 | protected function setUnsigned ( Field & $ field , $ type ) { if ( strpos ( $ type , 'unsigned' ) !== false ) { $ field -> isUnsigned = true ; $ field -> validationRules [ ] = sprintf ( 'min:%s' , 0 ) ; } return $ this ; } | Set the unsiged flag for a given field . |
40,992 | protected function setDataType ( Field & $ field , $ type ) { $ map = $ this -> dataTypeMap ( ) ; if ( array_key_exists ( $ type , $ map ) ) { $ field -> dataType = $ map [ $ type ] ; } return $ this ; } | Set the data type for a given field . |
40,993 | protected function setMaxLength ( Field & $ field , $ length ) { if ( ( $ value = intval ( $ length ) ) > 0 ) { $ field -> validationRules [ ] = sprintf ( 'max:%s' , $ value ) ; $ field -> methodParams [ ] = $ value ; } return $ this ; } | Set the max length for a given field . |
40,994 | protected function setLabel ( Field & $ field , $ name ) { $ field -> addLabel ( $ this -> getLabelName ( $ name ) , $ this -> tableName , true , $ this -> locale ) ; return $ this ; } | Set the labels for a given field . |
40,995 | protected function setKey ( Field & $ field , $ key , $ extra ) { $ key = strtoupper ( $ key ) ; if ( $ key == 'PRIMARY KEY' ) { $ field -> isPrimary = true ; } if ( $ key == 'MUL' ) { $ field -> isIndex = true ; } if ( $ key == 'UNI' ) { $ field -> isUnique = true ; } if ( strtolower ( $ extra ) == 'auto_increment' ) ... | Set the keys for a given field . |
40,996 | public function addLabel ( $ text , $ isPlain = true , $ lang = 'en' ) { $ this -> labels [ $ lang ] = new Label ( $ text , $ this -> getLocaleKey ( ) , $ isPlain , $ lang , $ this -> name ) ; } | Adds a label to the labels collection |
40,997 | public function addPlaceholder ( $ text , $ isPlain = true , $ lang = 'en' ) { $ value = '__placeholder' ; $ this -> placeholders [ $ lang ] = new Label ( $ text , $ this -> getLocaleKey ( '_placeholder' ) , $ isPlain , $ lang , $ this -> name . $ value ) ; } | Adds a label to the placeholders collection |
40,998 | protected function setPlaceholder ( array $ properties ) { $ labels = $ this -> getPlaceholderFromArray ( $ properties ) ; foreach ( $ labels as $ label ) { $ this -> addPlaceholder ( $ label -> text , $ label -> isPlain , $ label -> lang ) ; } return $ this ; } | It set the placeholder property for a given field |
40,999 | protected function getLabelsFromArray ( array $ items ) { $ labels = [ ] ; foreach ( $ items as $ key => $ label ) { $ lang = empty ( $ key ) || is_numeric ( $ key ) ? $ this -> defaultLang : $ key ; $ labels [ ] = new Label ( $ label , $ this -> localeGroup , false , $ lang ) ; } return $ labels ; } | It get the labels from a given array |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.