idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
40,800 | public function delete ( Model $ m , $ id , $ table = null ) { if ( ! isset ( $ table ) ) { $ table = $ m -> table ; } unset ( $ this -> data [ $ table ] [ $ id ] ) ; } | Deletes record in data array . |
40,801 | public function initAction ( Model $ m , $ fields = null ) { $ keys = $ fields ? array_flip ( $ fields ) : null ; $ data = array_map ( function ( $ r ) use ( $ m , $ keys ) { return $ this -> typecastLoadRow ( $ m , $ keys ? array_intersect_key ( $ r , $ keys ) : $ r ) ; } , $ this -> data [ $ m -> table ] ) ; return n... | Typecast data and return Iterator of data array . |
40,802 | public function action ( $ m , $ type , $ args = [ ] ) { if ( ! is_array ( $ args ) ) { throw new Exception ( [ '$args must be an array' , 'args' => $ args , ] ) ; } $ action = $ this -> initAction ( $ m , isset ( $ args [ 0 ] ) ? $ args [ 0 ] : null ) ; $ this -> applyConditions ( $ m , $ action ) ; $ this -> setLimit... | Various actions possible here mostly for compatibility with SQLs . |
40,803 | public function addField ( $ field , $ their_field = null ) : Field_SQL_Expression { if ( is_array ( $ field ) ) { $ defaults = $ field ; if ( ! isset ( $ defaults [ 0 ] ) ) { throw new Exception ( [ 'Field name must be specified' , 'field' => $ field , ] ) ; } $ field = $ defaults [ 0 ] ; unset ( $ defaults [ 0 ] ) ; ... | Creates expression which sub - selects a field inside related model . |
40,804 | public function ref ( $ defaults = [ ] ) : Model { $ m = parent :: ref ( $ defaults ) ; if ( ! $ this -> owner -> loaded ( ) && isset ( $ this -> owner -> persistence ) && $ this -> owner -> persistence instanceof Persistence_SQL ) { $ values = $ this -> owner -> action ( 'field' , [ $ this -> our_field ] ) ; return $ ... | Navigate to referenced model . |
40,805 | public function addTitle ( $ defaults = [ ] ) : Field_SQL_Expression { if ( ! is_array ( $ defaults ) ) { throw new Exception ( [ 'Argument to addTitle should be an array' , 'arg' => $ defaults , ] ) ; } $ field = isset ( $ defaults [ 'field' ] ) ? $ defaults [ 'field' ] : preg_replace ( '/_' . ( $ this -> owner -> id_... | Add a title of related entity as expression to our field . |
40,806 | public function getDSQLExpression ( $ expression ) { $ expr = $ this -> expr ; if ( is_callable ( $ expr ) ) { $ c = $ this -> expr ; $ expr = $ c ( $ this -> owner , $ expression ) ; } if ( is_string ( $ expr ) ) { if ( $ this -> owner -> hasMethod ( 'expr' ) ) { return $ this -> owner -> expr ( '([])' , [ $ this -> o... | When field is used as expression this method will be called . |
40,807 | public function normalize ( $ value ) { if ( is_null ( $ value ) || $ value === '' ) { return ; } if ( is_bool ( $ value ) ) { return $ value ; } if ( $ value === $ this -> valueTrue ) { return true ; } if ( $ value === $ this -> valueFalse ) { return false ; } if ( is_numeric ( $ value ) ) { return ( bool ) $ value ; ... | Normalize value to boolean value . |
40,808 | public function validate ( $ value ) { if ( $ this -> required && $ value !== $ this -> valueTrue ) { throw new ValidationException ( [ $ this -> name => 'Must be selected' ] ) ; } } | Validate if value is allowed for this field . |
40,809 | public function afterAdd ( $ p , $ m ) { if ( $ p -> titleForModel ) { $ m -> title_field = $ p -> titleForModel ; } foreach ( $ this -> fieldsForModel as $ field => $ def ) { if ( $ m -> hasField ( $ field ) ) { continue ; } $ m -> addField ( $ field , $ def ) ; } } | Automatically adds missing model fields . Called from AfterAdd hook . |
40,810 | public function normalize ( $ value ) { if ( $ value instanceof Expression || $ value instanceof Expressionable ) { return $ value ; } return parent :: normalize ( $ value ) ; } | SQL fields are allowed to have expressions inside of them . |
40,811 | public function getFiles ( ) { $ files = $ this -> getGeneralFiles ( ) ; if ( $ this -> option ( 'domain' ) && ! $ this -> option ( 'lucid' ) ) { return array_replace_recursive ( $ files , $ this -> getDomainStubPaths ( ) ) ; } if ( $ this -> option ( 'lucid' ) ) { return array_merge ( $ files , $ this -> getLucidPaths... | Get the destination paths . |
40,812 | public function getGeneralFiles ( ) { $ name = $ this -> getParsedNameInput ( ) ; return [ 'routes' => [ 'path' => '/routes/' . $ name . '.php' , 'stub' => __DIR__ . '/../stubs/routes/routes.stub' , ] , 'middleware' => [ 'path' => '/app/Http/Middleware/RedirectIfNot' . ucfirst ( $ name ) . '.php' , 'stub' => __DIR__ . ... | Get the default destination paths . |
40,813 | public function getLucidPaths ( ) { $ name = $ this -> getParsedNameInput ( ) ; $ service = $ this -> getParsedServiceInput ( ) ; $ lucidPaths = [ 'routes' => [ 'path' => '/src/Services/' . studly_case ( $ service ) . '/Http/' . $ name . '-routes.php' , 'stub' => __DIR__ . '/../stubs/Lucid/routes/routes.stub' , ] , 'mi... | Get the specific Lucid paths . |
40,814 | public function getSettings ( ) { $ lucid = $ this -> option ( 'lucid' ) ; $ settings = $ this -> getGeneralSettings ( ) ; if ( $ this -> option ( 'domain' ) && ! $ lucid ) { return array_replace_recursive ( $ settings , $ this -> getDomainMapMethod ( ) ) ; } if ( $ lucid ) { $ lucidSettings = array_merge ( $ settings ... | Get the necessary settings override if necessary . |
40,815 | public function getGeneralSettings ( ) { return [ 'guard' => [ 'path' => '/config/auth.php' , 'search' => "'guards' => [" , 'stub' => __DIR__ . '/../stubs/config/guards.stub' , 'prefix' => false , ] , 'provider' => [ 'path' => '/config/auth.php' , 'search' => "'providers' => [" , 'stub' => __DIR__ . '/../stubs/config/p... | Get the general settings . |
40,816 | public function getLucidSettings ( ) { $ service = $ this -> getParsedServiceInput ( ) ; $ general = [ 'provider' => [ 'path' => '/config/auth.php' , 'search' => "'providers' => [" , 'stub' => __DIR__ . '/../stubs/Lucid/config/providers.stub' , 'prefix' => false , ] , 'kernel' => [ 'path' => '/app/Http/Kernel.php' , 's... | Get the specific settings for the Lucid options . |
40,817 | public function installMigration ( ) { $ name = $ this -> getParsedNameInput ( ) ; $ migrationDir = base_path ( ) . '/database/migrations/' ; $ migrationName = 'create_' . str_plural ( snake_case ( $ name ) ) . '_table.php' ; $ migrationStub = new SplFileInfo ( __DIR__ . '/../stubs/Model/migration.stub' ) ; $ files = $... | Install Migration . |
40,818 | public function replaceNames ( $ template ) { $ name = $ this -> getParsedNameInput ( ) ; $ service = $ this -> getParsedServiceInput ( ) ; $ name = str_plural ( $ name ) ; $ plural = [ '{{pluralCamel}}' , '{{pluralSlug}}' , '{{pluralSnake}}' , '{{pluralClass}}' , ] ; $ singular = [ '{{singularCamel}}' , '{{singularSlu... | Replace names with pattern . |
40,819 | public function getFiles ( ) { $ name = $ this -> getParsedNameInput ( ) ; $ lucid = $ this -> option ( 'lucid' ) ; return [ 'model' => [ 'path' => ! $ lucid ? '/app/' . ucfirst ( $ name ) . '.php' : '/src/Data/' . ucfirst ( $ name ) . '.php' , 'stub' => ! $ lucid ? __DIR__ . '/../stubs/Model/Model.stub' : __DIR__ . '/... | Get the destination path . |
40,820 | public function build ( $ id , array $ config = [ ] ) { $ id = $ this -> dereference ( $ id ) ; if ( isset ( $ this -> building [ $ id ] ) ) { throw new CircularReferenceException ( sprintf ( 'Circular reference to "%s" detected while building: %s; dereferencing: %s' , $ id , implode ( ',' , array_keys ( $ this -> buil... | Creates new instance by either interface name or alias . |
40,821 | protected function buildWithoutDefinition ( $ id , array $ config = [ ] ) { if ( isset ( $ config [ '__class' ] ) ) { return $ this -> buildFromConfig ( $ id , $ config ) ; } if ( $ this -> parent !== null ) { return $ this -> parent -> build ( $ id , $ config ) ; } if ( class_exists ( $ id ) ) { $ config [ '__class' ]... | Creates new instance without definition in container . |
40,822 | protected function buildWithDefinition ( $ id , array $ config = [ ] , $ definition = null ) { if ( \ is_string ( $ definition ) ) { if ( $ definition !== $ id ) { return $ this -> build ( $ definition , $ config ) ; } $ definition = [ '__class' => $ definition ] ; } if ( \ is_array ( $ definition ) && ! isset ( $ defi... | Creates new instance by given config and definition . |
40,823 | public function setAll ( $ config ) : void { foreach ( $ config as $ id => $ definition ) { $ this -> set ( $ id , $ definition ) ; } } | Sets multiple definitions at once . |
40,824 | public function has ( $ id ) : bool { $ id = $ this -> dereference ( $ id ) ; return isset ( $ this -> definitions [ $ id ] ) ; } | Returns a value indicating whether the container has the definition of the specified name . |
40,825 | protected function dereference ( $ id ) : string { if ( $ id instanceof Reference ) { $ id = $ id -> getId ( ) ; } if ( ! isset ( $ this -> definitions [ $ id ] ) || ! $ this -> definitions [ $ id ] instanceof Reference ) { return $ id ; } if ( isset ( $ this -> dereferencing [ $ id ] ) ) { throw new CircularReferenceE... | Follows references recursively to find the deepest ID . |
40,826 | protected function buildFromConfig ( $ id , array $ config ) { if ( empty ( $ config [ '__class' ] ) ) { $ config [ '__class' ] = $ id ; } if ( empty ( $ config [ '__class' ] ) ) { throw new NotInstantiableException ( var_export ( $ config , true ) ) ; } [ $ reflection , $ dependencies ] = $ this -> getDependencies ( $... | Creates an instance of the class definition with dependencies resolved |
40,827 | public static function configure ( $ object , iterable $ config ) { foreach ( $ config as $ action => $ arguments ) { if ( substr ( $ action , - 2 ) === '()' ) { \ call_user_func_array ( [ $ object , substr ( $ action , 0 , - 2 ) ] , $ arguments ) ; } else { $ object -> $ action = $ arguments ; } } return $ object ; } | Configures an object with the given configuration . |
40,828 | protected function resolveDependencies ( $ dependencies , $ reflection = null ) : array { foreach ( $ dependencies as $ index => $ dependency ) { if ( $ dependency instanceof Reference ) { if ( $ dependency -> getId ( ) !== null ) { $ dependencies [ $ index ] = $ this -> get ( $ dependency -> getId ( ) ) ; } elseif ( $... | Resolves dependencies by replacing them with the actual object instances . |
40,829 | public function addProvider ( $ providerDefinition ) : void { $ provider = $ this -> buildProvider ( $ providerDefinition ) ; if ( $ provider instanceof DeferredServiceProviderInterface ) { $ this -> deferredProviders -> attach ( $ provider ) ; } else { $ provider -> register ( ) ; } } | Adds service provider to the container . Unless service provider is deferred it would be immediately registered . |
40,830 | protected function buildProvider ( $ providerDefinition ) : ServiceProviderInterface { if ( \ is_string ( $ providerDefinition ) ) { $ provider = $ this -> buildFromConfig ( null , [ '__class' => $ providerDefinition , '__construct()' => [ $ this , ] ] ) ; } elseif ( \ is_array ( $ providerDefinition ) && isset ( $ pro... | Builds service provider by definition . |
40,831 | public function get ( $ id ) { $ id = $ this -> dereference ( $ id ) ; if ( isset ( $ this -> instances [ $ id ] ) ) { return $ this -> instances [ $ id ] ; } $ object = $ this -> build ( $ id ) ; $ this -> instances [ $ id ] = $ object ; return $ this -> initObject ( $ object ) ; } | Returns an instance by either interface name or alias . |
40,832 | public function hasInstance ( $ id ) : bool { $ id = $ this -> dereference ( $ id ) ; return isset ( $ this -> instances [ $ id ] ) ; } | Returns a value indicating whether the container has already instantiated instance of the specified name . |
40,833 | protected function initTools ( ) { if ( $ this -> expandable === true || $ this -> collapsable === true ) { $ this -> tools [ ] = [ 'encode' => false , 'label' => new Icon ( 'chevron-' . ( $ this -> expandable === true ? 'down' : 'up' ) ) , 'linkOptions' => [ 'class' => 'collapse-link' ] , 'url' => null , ] ; } if ( em... | Init tool buttons |
40,834 | public static function plural ( $ word ) { $ definitions = Config :: getPluralDefinitions ( ) ; if ( array_key_exists ( $ word , $ definitions ) ) { return $ definitions [ $ word ] ; } return LaravelStr :: plural ( $ word ) ; } | Gets a plural version of a given word . |
40,835 | public static function singular ( $ word ) { $ definitions = Config :: getPluralDefinitions ( ) ; if ( ( $ singular = array_search ( $ word , $ definitions ) ) !== false ) { return $ singular ; } return LaravelStr :: singular ( $ word ) ; } | Gets a singular version of a given word . |
40,836 | public static function makeControllerName ( $ modelName ) { $ name = self :: getProperCaseFor ( $ modelName , 'controller-name' ) ; $ case = ucfirst ( camel_case ( $ name ) ) ; if ( ! empty ( $ postFix = Config :: getControllerNamePostFix ( ) ) ) { return str_finish ( $ case , $ postFix ) ; } return $ case ; } | Makes a controller name from a given model name |
40,837 | public static function eliminateDupilcates ( $ subject , $ eliminate = "\\" ) { $ pattern = $ eliminate . $ eliminate ; while ( strpos ( $ subject , $ pattern ) !== false ) { $ subject = str_replace ( $ pattern , $ eliminate , $ subject ) ; } return $ subject ; } | Eliminate a duplicate given phrase from a given string |
40,838 | public static function inArraySearch ( array $ subjects , $ search ) { foreach ( $ subjects as $ subject ) { if ( str_is ( $ search . '*' , $ subject ) ) { return true ; } } return false ; } | Checks an array for the first value that starts with a given pattern |
40,839 | public static function makeFormRequestName ( $ modelName ) { $ name = self :: getProperCaseFor ( $ modelName , 'request-form-name' ) ; $ case = ucfirst ( camel_case ( $ name ) ) ; if ( ! empty ( $ postFix = Config :: getFormRequestNamePostFix ( ) ) ) { return str_finish ( $ case , $ postFix ) ; } return $ case ; } | Makes a form request class name of the givin model s name |
40,840 | public static function getLanguageItems ( array $ fields ) { $ items = [ ] ; foreach ( $ fields as $ field ) { foreach ( $ field -> getLabels ( ) as $ label ) { if ( ! $ label -> isPlain ) { $ items [ $ label -> lang ] [ ] = $ label ; } } foreach ( $ field -> getPlaceholders ( ) as $ label ) { if ( ! $ label -> isPlain... | Creates a colection of messages out of a given fields collection . |
40,841 | public static function guessModelFullName ( $ name , $ modelsPath ) { $ model = $ modelsPath . ucfirst ( self :: extractModelName ( $ name ) ) ; return self :: convertSlashToBackslash ( $ model ) ; } | Guesses the model full name using the given field s name |
40,842 | public static function extractModelName ( $ name ) { $ name = self :: removePostFixWith ( $ name , '_id' ) ; return ucfirst ( studly_case ( Str :: singular ( $ name ) ) ) ; } | Extracts the model name from the given field s name . |
40,843 | public static function isKeyExists ( array $ properties , ... $ name ) { $ args = func_get_args ( ) ; for ( $ i = 1 ; $ i < count ( $ args ) ; $ i ++ ) { if ( ! array_key_exists ( $ args [ $ i ] , $ properties ) ) { return false ; } } return true ; } | Checks if a key exists in a given array |
40,844 | public static function getProperCaseFor ( $ modelName , $ key = null ) { $ snake = snake_case ( $ modelName ) ; if ( Config :: shouldBePlural ( $ key ) ) { return Str :: plural ( $ snake ) ; } return $ snake ; } | Makes the proper english case given a model name and a file type |
40,845 | public static function strReplaceOnce ( $ pattern , $ replacment , $ subject ) { $ index = strpos ( $ subject , $ pattern ) ; if ( $ index !== false ) { return substr_replace ( $ subject , $ replacment , $ index , strlen ( $ pattern ) ) ; } return $ subject ; } | Replaces found pattern in a subject only one time . |
40,846 | public static function removeEmptyItems ( array $ items , $ callback = null ) { $ final = [ ] ; foreach ( $ items as $ item ) { $ item = trim ( $ item ) ; $ item = ! is_null ( $ callback ) && is_callable ( $ callback ) ? call_user_func ( $ callback , $ item ) : $ item ; if ( ! empty ( $ item ) ) { $ final [ ] = $ item ... | It trims each element in a givin array and removes the empty elements . If a callback is passed as a second parameter the callbacl is applied on each item . |
40,847 | public static function strIs ( $ patterns , $ subject , & $ matchedPattern = '' , $ caseSensitive = false ) { if ( ! is_array ( $ patterns ) ) { $ patterns = ( array ) $ patterns ; } $ lowerSubject = strtolower ( $ subject ) ; foreach ( $ patterns as $ pattern ) { if ( $ caseSensitive ) { if ( str_is ( $ pattern , $ su... | Checks if a string matches at least one given pattern |
40,848 | public static function removePostFixWith ( $ name , $ fix = '/' ) { $ position = strripos ( $ name , $ fix ) ; if ( $ position !== false ) { return substr ( $ name , 0 , $ position ) ; } return $ name ; } | Removes a string from the end of another given string if it already ends with it . |
40,849 | public static function upperCaseEveyWord ( $ sentence , $ delimiter = '\\' ) { $ words = explode ( $ delimiter , $ sentence ) ; return implode ( $ delimiter , array_map ( 'ucfirst' , $ words ) ) ; } | Turns every word in a path to uppercase |
40,850 | public static function wrapItems ( array $ items , $ wrapper = "'" ) { return array_map ( function ( $ item ) use ( $ wrapper ) { $ item = str_replace ( $ wrapper , '\\' . $ wrapper , trim ( $ item , $ wrapper ) ) ; return sprintf ( '%s%s%s' , $ wrapper , $ item , $ wrapper ) ; } , $ items ) ; } | Wrapps each item in an array with a given string |
40,851 | protected function getCommandOptions ( $ input ) { return [ 'model-name' => $ this -> argument ( 'model-name' ) , '--resource-filename' => $ this -> option ( 'resource-filename' ) , '--fields' => $ this -> option ( 'fields' ) , '--translation-for' => $ this -> option ( 'translation-for' ) , '--relations' => $ this -> o... | Converts the current command s argument and options into an array . |
40,852 | protected function createMigration ( $ input ) { if ( $ input -> withMigration ) { $ this -> call ( 'create:migration' , [ 'model-name' => $ input -> modelName , '--table-name' => $ input -> table , '--migration-class-name' => $ input -> migrationClass , '--connection-name' => $ input -> connectionName , '--engine-name... | Executes the command that generates a migration . |
40,853 | protected function createResourceFile ( $ input ) { $ this -> call ( 'resource-file:from-database' , [ 'model-name' => $ input -> modelName , '--table-name' => $ input -> table , '--resource-filename' => $ input -> resourceFile , '--translation-for' => $ input -> translationFor , '--force' => $ input -> force , ] ) ; r... | Executes the command that generate fields file . |
40,854 | protected function createLanguage ( $ input ) { if ( ! $ this -> option ( 'without-languages' ) ) { $ this -> call ( 'create:language' , [ 'model-name' => $ input -> modelName , '--language-filename' => $ input -> languageFileName , '--resource-file' => $ input -> resourceFile , '--template-name' => $ input -> template... | Executes the command that generates a language files . |
40,855 | protected function createViews ( $ input ) { if ( ! $ this -> option ( 'without-views' ) ) { $ this -> call ( 'create:views' , [ 'model-name' => $ input -> modelName , '--resource-file' => $ input -> resourceFile , '--views-directory' => $ input -> viewsDirectory , '--routes-prefix' => $ input -> prefix , '--layout-nam... | Executes the command that generates all the views . |
40,856 | protected function createRoutes ( $ input ) { $ this -> call ( 'create:routes' , [ 'model-name' => $ input -> modelName , '--controller-name' => $ input -> controllerName , '--routes-prefix' => $ input -> prefix , '--template-name' => $ input -> template , '--controller-directory' => $ input -> controllerDirectory , ] ... | Executes the command that generates the routes . |
40,857 | protected function createController ( $ input ) { if ( ! $ this -> option ( 'without-controller' ) ) { $ this -> call ( 'create:controller' , [ 'model-name' => $ input -> modelName , '--controller-name' => $ input -> controllerName , '--controller-directory' => $ input -> controllerDirectory , '--controller-extends' =>... | Executes the command that generates the controller . |
40,858 | protected function createModel ( $ input ) { if ( ! $ this -> option ( 'without-model' ) ) { $ this -> call ( 'create:model' , [ 'model-name' => $ input -> modelName , '--table-name' => $ input -> table , '--primary-key' => $ input -> primaryKey , '--resource-file' => $ input -> resourceFile , '--model-directory' => $ ... | Executes the command that generates a model . |
40,859 | protected function getRawProperty ( $ name ) { if ( property_exists ( $ this , 'name' ) ) { if ( ! is_null ( $ this -> { $ name } ) && $ this -> { $ name } instanceof JsonWriter ) { return $ this -> { $ name } -> toArray ( ) ; } } return null ; } | Get a raw property using the given property name |
40,860 | public static function first ( $ value , $ key = 'model-name' ) { $ file = self :: getMapper ( ) ; if ( File :: Exists ( $ file ) ) { $ maps = self :: getMaps ( $ file ) ; return Collect ( $ maps ) -> first ( function ( $ map ) use ( $ key , $ value ) { return isset ( $ map [ $ key ] ) && $ map [ $ key ] == $ value ; }... | Gets the first map with the given model name |
40,861 | protected function mapExists ( array $ map , $ modelName , $ tableName = null ) { $ found = isset ( $ map [ 'model-name' ] ) && $ map [ 'model-name' ] == $ modelName ; if ( ! $ found && ! empty ( $ tableName ) ) { $ found = isset ( $ map [ 'table-name' ] ) && $ map [ 'table-name' ] == $ tableName ; } return $ found ; } | Checks if a map exists |
40,862 | public function getDelta ( Resource $ resourceA , Resource $ resourceB , MigrationInput $ input ) { $ fieldChanges = $ this -> getFieldsDelta ( $ resourceA -> fields , $ resourceB -> fields ) ; $ indexChanges = $ this -> getIndexesDelta ( $ resourceA -> indexes , $ resourceB -> indexes ) ; $ changeCapsule = new Migrati... | Get the difference between a givin resource and the resource in the current migration |
40,863 | protected function getFieldsDelta ( array $ fieldsA , array $ fieldsB ) { $ currentFields = Collect ( $ fieldsB ) -> keyBy ( 'name' ) ; $ currentFieldNames = $ currentFields -> keys ( ) -> toArray ( ) ; $ requestedFields = Collect ( $ fieldsA ) -> keyBy ( 'name' ) ; $ requestedFieldNames = $ requestedFields -> keys ( )... | Get the field difference between two given Field arrays |
40,864 | protected function getIndexesDelta ( array $ indexesA , array $ indexesB ) { $ currentIndexes = Collect ( $ indexesA ) ; $ currentIndexNames = $ currentIndexes -> pluck ( 'name' ) ; $ requestedIndexes = Collect ( $ indexesB ) ; $ requestedIndexNames = $ requestedIndexes -> pluck ( 'name' ) ; $ updatedIndexes = $ curren... | Get the field difference between two given Index arrays |
40,865 | public function getMigrationIndex ( $ name ) { foreach ( $ this -> getMigrations ( ) as $ key => $ migration ) { if ( $ migration -> name == $ name ) { return $ key ; } } return - 1 ; } | Get the index of a migration by name . It return - 1 if not found . |
40,866 | public function forgetMigration ( $ index ) { if ( ( $ current = $ this -> migrations [ $ index ] ) !== null ) { $ this -> deleteFile ( $ current -> path ) ; unset ( $ this -> migrations [ $ index ] ) ; } } | Deletes a migration by index |
40,867 | public function isCurrentMigration ( $ name ) { $ current = $ this -> getCurrentMigration ( ) ; return ( ! is_null ( $ current ) && $ current -> name == $ name ) ; } | Checks if the given migration name is the current one |
40,868 | public function migrationHasSoftDelete ( ) { $ hasSoftDelete = false ; foreach ( $ this -> getMigrations ( ) as $ migration ) { if ( $ this -> isCurrentMigration ( $ migration -> name ) && ! $ migration -> isMigrated ( ) ) { continue ; } if ( $ hasSoftDelete && ! $ migration -> withSoftDelete ) { $ hasSoftDelete = fals... | Checks the migration history to see if the migration has a soft - delete not . |
40,869 | public function migrationHasTimestamps ( ) { $ hasTimestamps = false ; foreach ( $ this -> getMigrations ( ) as $ migration ) { if ( $ this -> isCurrentMigration ( $ migration -> name ) && ! $ migration -> isMigrated ( ) ) { continue ; } if ( $ hasTimestamps && $ migration -> withoutTimestamps ) { $ hasTimestamps = fal... | Checks the migration history to see if the migration has a timestamps not . |
40,870 | protected function getRelations ( $ relations ) { $ existingNames = [ ] ; $ finalRelations = [ ] ; foreach ( $ relations as $ relation ) { $ newRelation = ForeignRelationship :: fromString ( $ relation ) ; if ( is_null ( $ newRelation ) ) { continue ; } if ( ! empty ( $ newRelation -> name ) && in_array ( $ newRelation... | Get the relations from an existing array . |
40,871 | protected function getIndexes ( $ indexes ) { $ existingNames = [ ] ; $ finalIndexes = [ ] ; foreach ( $ indexes as $ index ) { $ newIndex = Index :: fromString ( $ index ) ; if ( ! empty ( $ newIndex -> getName ( ) ) && in_array ( $ newIndex -> getName ( ) , $ existingNames ) ) { continue ; } $ finalIndexes [ ] = $ ne... | Get the indexes from an existing array . |
40,872 | protected function getRequiredUseClasses ( array $ fields , $ withAuth ) { $ commands = [ ] ; if ( $ withAuth ) { $ commands [ ] = $ this -> getUseClassCommand ( 'Auth' ) ; } foreach ( $ fields as $ field ) { $ customRules = $ this -> extractCustomValidationRules ( $ field -> getValidationRule ( ) ) ; $ namespaces = $ ... | Gets the using statement for Auth . |
40,873 | public function setProtection ( $ name , $ isProtected ) { $ key = $ this -> getProtectionKey ( $ name ) ; $ this -> protection [ $ key ] = ( bool ) $ isProtected ; } | Sets the database s table name . |
40,874 | public function isProtected ( $ name ) { $ key = $ this -> getProtectionKey ( $ name ) ; if ( array_key_exists ( $ key , $ this -> getProtections ( ) ) ) { return ( bool ) $ this -> getProtections ( ) [ $ key ] ; } return false ; } | Checks if the given resource is protected or not . |
40,875 | public function isEmpty ( ) { return empty ( $ this -> fields ) && empty ( $ this -> relations ) && empty ( $ this -> indexes ) ; } | Checks if the resource is empty . |
40,876 | public function pluckFields ( $ property = 'name' ) { $ names = [ ] ; if ( $ this -> hasFields ( ) ) { foreach ( $ this -> getFields ( ) as $ field ) { if ( property_exists ( $ field , $ property ) ) { $ names [ ] = $ field -> { $ property } ; } } } return $ names ; } | Extracts the given property name from the fields |
40,877 | public function toArray ( ) { return [ 'fields' => $ this -> getFieldsToArray ( ) , 'relations' => $ this -> getRelationsToArray ( ) , 'indexes' => $ this -> getIndexesToArray ( ) , 'auto-manage-created-and-updated-at' => $ this -> isCreateAndUpdateAtManaged ( ) , 'table-name' => $ this -> getTableName ( ) , 'protectio... | Converts the object into a json - ready array |
40,878 | protected function getRawProtections ( ) { $ protected = [ ] ; foreach ( $ this -> protectableResources as $ name ) { $ key = $ this -> getProtectionKey ( $ name ) ; $ protected [ $ key ] = $ this -> isProtected ( $ key ) ; } return $ protected ; } | Converts the protection into a json - ready array |
40,879 | public static function fromFile ( $ filename , $ localeGroup , array $ languages = [ ] ) { $ content = self :: jsonFileContent ( $ filename ) ; return self :: fromJson ( $ content , $ localeGroup , $ languages ) ; } | It transfres a given string to a collection of field |
40,880 | public static function fromJson ( $ json , $ localeGroup , array $ languages = [ ] ) { if ( empty ( $ json ) || ( $ capsule = json_decode ( $ json , true ) ) === null ) { throw new Exception ( "The provided string is not a valid json." ) ; } if ( is_array ( $ capsule ) && ! Helpers :: isAssociative ( $ capsule ) ) { $ ... | It transfres a given JSON string to a collection of field |
40,881 | public static function fromArray ( array $ properties , $ localeGroup , array $ languages = [ ] ) { $ resource = new Resource ( ) ; if ( array_key_exists ( 'fields' , $ properties ) && is_array ( $ properties [ 'fields' ] ) ) { $ resource -> fields = FieldTransformer :: fromArray ( $ properties [ 'fields' ] , $ localeG... | It transfres a gving array to a resource |
40,882 | public static function jsonFileContent ( $ filename ) { $ fileFullname = Config :: getResourceFilePath ( $ filename ) ; if ( ! File :: exists ( $ fileFullname ) ) { throw new Exception ( 'The resource file ' . $ fileFullname . ' was not found! Perhaps, you need to run PHP artisan resource-file:create [model-name] or r... | Gets the content of the resource json file . |
40,883 | public function getHtmlFields ( ) { $ htmlFields = '' ; foreach ( $ this -> fields as $ field ) { if ( ! $ field -> isOnFormView ) { continue ; } $ parser = new ValidationParser ( $ field -> validationRules ) ; if ( in_array ( $ field -> htmlType , [ 'select' , 'multipleSelect' ] ) ) { $ htmlFields .= $ this -> getSele... | Gets html field for the current set fields . |
40,884 | public function getShowRowsHtml ( array $ fields = null ) { $ rows = '' ; $ stub = $ this -> getStubContent ( 'show.row.blade' , $ this -> template ) ; foreach ( $ this -> getFieldsToDisplay ( $ fields ) as $ field ) { if ( $ field -> isOnShowView ) { $ rows .= $ this -> getShowRowHtmlField ( $ stub , $ field ) . PHP_E... | Gets html code for the show view using the current fields colelction . If an value is passed it will only generate the raws based on the given fields |
40,885 | protected function getShowRowHtmlField ( $ stub , Field $ field ) { $ this -> replaceFieldName ( $ stub , $ field -> name ) -> replaceModelName ( $ stub , $ this -> modelName ) -> replaceRowFieldValue ( $ stub , $ this -> getFieldValueForShow ( $ field ) ) -> replaceFieldTitle ( $ stub , $ this -> getTitle ( $ field ->... | Gets show row html code for the given field . |
40,886 | protected function getFieldValueForShow ( Field $ field ) { if ( $ field -> isFile ( ) ) { return sprintf ( "asset('storage/' . %s)" , $ this -> getFieldAccessorValue ( $ field , 'show' ) ) ; } return $ this -> getFieldAccessorValue ( $ field , 'show' ) ; } | Gets the value to use in the show view |
40,887 | public function getIndexHeaderCells ( array $ fields = null ) { $ stub = $ this -> getStubContent ( 'index.header.cell.blade' , $ this -> template ) ; $ fields = $ this -> getFieldsToDisplay ( $ fields ) ; $ rows = '' ; foreach ( $ fields as $ field ) { if ( $ field -> isOnIndexView ) { $ row = $ stub ; $ this -> repla... | Gets header cells html code for the index view using the current fields colelction . If an value is passed it will only generate the raws based on the given fields |
40,888 | public function replaceCommonTemplates ( & $ stub , Field $ field ) { return $ this -> replaceFieldName ( $ stub , $ field -> name ) -> replaceModelName ( $ stub , $ this -> modelName ) -> replaceCssClass ( $ stub , $ field -> cssClass ) -> replaceFieldType ( $ stub , $ field -> htmlType ) -> replaceFieldTitle ( $ stub... | Replaces field s common templates |
40,889 | public function getIndexBodyCells ( array $ fields = null ) { $ rows = '' ; $ stub = $ this -> getStubContent ( 'index.body.cell.blade' , $ this -> template ) ; foreach ( $ this -> getFieldsToDisplay ( $ fields ) as $ field ) { if ( $ field -> isOnIndexView ) { $ rows .= $ this -> getIndexBodyCell ( $ stub , $ field ) ... | Gets header body s html code for the index view using the current fields colelction . If an value is passed it will only generate the raws based on the given fields |
40,890 | protected function getIndexBodyCell ( $ stub , Field $ field ) { $ this -> replaceFieldName ( $ stub , $ field -> name ) -> replaceModelName ( $ stub , $ this -> modelName ) -> replaceRowFieldValue ( $ stub , $ this -> getFieldAccessorValue ( $ field , 'index' ) ) -> replaceFieldTitle ( $ stub , $ this -> getTitle ( $ ... | Gets index body cell html code for the given field . |
40,891 | protected function getFieldAccessorValue ( Field $ field , $ view ) { $ fieldAccessor = sprintf ( '$%s->%s' , $ this -> getSingularVariable ( $ this -> modelName ) , $ field -> name ) ; if ( $ field -> hasForeignRelation ( ) && $ field -> isOnView ( $ view ) ) { $ relation = $ field -> getForeignRelation ( ) ; if ( Hel... | Gets a value accessor for the field . |
40,892 | protected function getFieldsToDisplay ( array $ fields = null ) { if ( ! empty ( $ fields ) ) { return array_filter ( $ this -> fields , function ( $ field ) use ( $ fields ) { return in_array ( $ field -> name , $ fields ) ; } ) ; } return $ this -> fields ; } | It find the union field between a given collection and the current field collection . If null is provided the current field collection is returned . |
40,893 | protected function getPickItemsHtmlField ( Field $ field , Label $ option , ValidationParser $ parser ) { $ filename = sprintf ( 'form-pickitems%s-field.blade' , $ field -> isInlineOptions ? '-inline' : '' ) ; $ stub = $ this -> getStubContent ( $ filename , $ this -> template ) ; $ fieldName = ( $ field -> isMultipleA... | Gets creates a checkbox or radio button html field for a given field . |
40,894 | protected function getSelectHtmlField ( Field $ field , ValidationParser $ parser ) { $ stub = $ this -> getStubContent ( 'form-selectmenu-field.blade' , $ this -> template ) ; $ fieldName = ( $ field -> isMultipleAnswers ( ) ) ? $ this -> getFieldNameAsArray ( $ field -> name ) : $ field -> name ; $ optionValue = $ th... | Gets creates an select menu html field for a given field . |
40,895 | protected function getFieldItem ( Field $ field ) { if ( $ field -> hasForeignRelation ( ) ) { $ relation = $ field -> getForeignRelation ( ) ; return sprintf ( '$%s' , $ relation -> getSingleName ( ) ) ; } return '$text' ; } | Gets the fields accessor |
40,896 | protected function getFieldItemAccessor ( Field $ field ) { if ( $ field -> hasForeignRelation ( ) ) { $ relation = $ field -> getForeignRelation ( ) ; return sprintf ( '$%s->%s' , $ relation -> getSingleName ( ) , $ relation -> getField ( ) ) ; } return '$text' ; } | Gets the fields item accessor |
40,897 | protected function getCheckedItemForPickItem ( $ value , $ name , $ isMultiple , $ defaultValue ) { return $ isMultiple ? $ this -> getMultipleCheckedItem ( $ value , $ name , $ defaultValue ) : $ this -> getCheckedItem ( $ value , $ name , $ defaultValue ) ; } | Gets the selected value for the pick items . |
40,898 | protected function getSelectedValueForMenu ( Field $ field ) { $ valueAccessor = $ this -> getFieldValueAccessor ( $ field ) ; if ( $ field -> isMultipleAnswers ( ) ) { return $ this -> getMultipleSelectedValue ( $ field -> name , $ valueAccessor , $ field -> htmlValue ) ; } return $ this -> getSelectedValue ( $ field ... | Gets the selected value for a menu . |
40,899 | public function getSelectRangeHtmlField ( Field $ field ) { $ stub = $ this -> getStubContent ( 'form-selectrange-field.blade' , $ this -> template ) ; $ this -> replaceFieldName ( $ stub , $ field -> name ) -> replaceCssClass ( $ stub , $ field -> cssClass ) -> replaceFieldMinValue ( $ stub , isset ( $ field -> range ... | Gets a rangeselector element for a given field . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.