idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
55,400 | public function getFieldObject ( $ options ) { $ class = $ this -> getFieldTypeClass ( $ options [ 'type' ] ) ; return new $ class ( $ this -> validator , $ this -> config , $ this -> db , $ options ) ; } | Instantiates a field object . |
55,401 | public function prepareOptions ( $ name , $ options , $ loadRelationships = true ) { $ options = $ this -> validateOptions ( $ name , $ options ) ; $ options [ 'title' ] = isset ( $ options [ 'title' ] ) ? $ options [ 'title' ] : $ options [ 'field_name' ] ; $ options [ 'hint' ] = isset ( $ options [ 'hint' ] ) ? $ opt... | Sets up an options array with the required base values . |
55,402 | public function ensureTypeIsSet ( array & $ options ) { if ( ! isset ( $ options [ 'type' ] ) ) { if ( $ this -> config -> getType ( ) === 'model' && $ options [ 'field_name' ] === $ this -> config -> getDataModel ( ) -> getKeyName ( ) ) { $ options [ 'type' ] = 'key' ; } else { $ options [ 'type' ] = 'text' ; } } } | Ensures that the type option is set . |
55,403 | public function setRelationshipType ( array & $ options , $ loadRelationships ) { if ( $ this -> validator -> arrayGet ( $ options , 'type' ) === 'relationship' ) { $ options [ 'type' ] = $ this -> getRelationshipKey ( $ options [ 'field_name' ] ) ; $ options [ 'load_relationships' ] = $ loadRelationships && ! $ this -... | Ensures that a relationship field is valid . |
55,404 | public function checkTypeExists ( array & $ options ) { if ( ! array_key_exists ( $ options [ 'type' ] , $ this -> fieldTypes ) ) { throw new \ InvalidArgumentException ( 'The ' . $ options [ 'type' ] . ' field type in your ' . $ this -> config -> getOption ( 'name' ) . ' configuration file is not valid' ) ; } if ( $ t... | Check to see if the type is valid . |
55,405 | public function getEditFieldsArrays ( $ override = false ) { $ return = array ( ) ; foreach ( $ this -> getEditFields ( true , $ override ) as $ fieldObject ) { $ return [ $ fieldObject -> getOption ( 'field_name' ) ] = $ fieldObject -> getOptions ( ) ; } if ( $ this -> config -> getType ( ) === 'model' ) { $ this -> f... | Gets the array version of the edit fields objects . |
55,406 | public function fillKeyField ( array & $ fields ) { $ model = $ this -> config -> getDataModel ( ) ; $ keyName = $ model -> getKeyName ( ) ; if ( $ this -> config -> getType ( ) === 'model' && ! isset ( $ fields [ $ keyName ] ) ) { $ keyField = $ this -> make ( $ keyName , array ( 'visible' => false ) ) ; $ fields [ $ ... | Gets the key field for a model for the getEditFieldsArrays . |
55,407 | public function getDataModel ( ) { $ dataModel = array ( ) ; $ model = $ this -> config -> getDataModel ( ) ; foreach ( $ this -> getEditFieldsArrays ( ) as $ name => $ options ) { if ( $ options [ 'type' ] === 'key' ) { $ dataModel [ $ name ] = 0 ; } else { if ( is_a ( $ model -> $ name , 'Illuminate\Database\Eloquent... | Gets the data model given the edit fields . |
55,408 | public function getFilters ( ) { $ configFilters = $ this -> config -> getOption ( 'filters' ) ; if ( empty ( $ this -> filters ) && $ configFilters ) { foreach ( $ configFilters as $ name => $ filter ) { if ( $ fieldObject = $ this -> make ( $ name , $ filter ) ) { $ this -> filters [ $ fieldObject -> getOption ( 'fie... | Gets the filters for the given model config . |
55,409 | public function getFiltersArrays ( ) { if ( empty ( $ this -> filtersArrays ) ) { foreach ( $ this -> getFilters ( ) as $ name => $ filter ) { $ this -> filtersArrays [ $ name ] = $ filter -> getOptions ( ) ; } } return $ this -> filtersArrays ; } | Gets the filters array and converts the objects to arrays . |
55,410 | public function filterBySearchTerm ( $ term , EloquentBuilder & $ query , Field $ fieldObject , array $ selectedItems , $ relatedKeyTable ) { if ( $ term ) { $ query -> where ( function ( $ query ) use ( $ term , $ fieldObject ) { foreach ( $ fieldObject -> getOption ( 'search_fields' ) as $ search ) { $ query -> orWhe... | Filters a relationship options query by a search term . |
55,411 | public function formatSelectOptions ( Field $ field , EloquentCollection $ results ) { $ return = array ( ) ; foreach ( $ results as $ m ) { $ return [ ] = array ( 'id' => $ m -> getKey ( ) , 'text' => strval ( $ m -> { $ field -> getOption ( 'name_field' ) } ) , ) ; } return $ return ; } | Takes an eloquent result array and turns it into an options array that can be used in the UI . |
55,412 | public function getNestedRelationships ( $ name ) { $ pieces = explode ( '.' , $ name ) ; $ models = array ( ) ; $ num_pieces = sizeof ( $ pieces ) ; foreach ( $ pieces as $ i => $ rel ) { if ( $ i === 0 ) { $ models [ ] = $ this -> config -> getDataModel ( ) ; } if ( ! method_exists ( $ models [ $ i ] , $ rel ) || ! i... | Converts the relationship key . |
55,413 | public function filterQuery ( QueryBuilder & $ query , & $ selects = null ) { parent :: filterQuery ( $ query , $ selects ) ; $ value = $ this -> getOption ( 'value' ) ; $ table = $ this -> getOption ( 'table' ) ; $ column = $ this -> getOption ( 'column' ) ; $ column2 = $ this -> getOption ( 'column2' ) ; if ( ! $ val... | Filters a query object with this item s data . |
55,414 | public function getOptions ( ) { if ( empty ( $ this -> options ) ) { $ this -> validateOptions ( ) ; $ this -> build ( ) ; $ this -> options = array_merge ( $ this -> getDefaults ( ) , $ this -> suppliedOptions ) ; } return $ this -> options ; } | Gets all user options . |
55,415 | public function getOption ( $ key ) { $ options = $ this -> getOptions ( ) ; if ( ! array_key_exists ( $ key , $ options ) ) { throw new \ InvalidArgumentException ( "An invalid option was searched for in the '" . $ options [ 'column_name' ] . "' column" ) ; } return $ options [ $ key ] ; } | Gets a field s option . |
55,416 | public function getStoragePath ( ) { $ path = $ this -> getOption ( 'storage_path' ) ; $ path = $ path ? $ path : storage_path ( ) . '/administrator_settings/' ; return rtrim ( $ path , '/' ) . '/' ; } | Gets the storage directory path . |
55,417 | public function fetchData ( array $ fields ) { $ data = array ( ) ; foreach ( $ fields as $ name => $ field ) { $ data [ $ name ] = null ; } $ this -> setDataModel ( $ this -> populateData ( $ data ) ) ; } | Fetches the data for this settings config and stores it in the data property . |
55,418 | public function populateData ( array $ data ) { $ path = $ this -> getStoragePath ( ) ; if ( ! is_dir ( $ path ) ) { mkdir ( $ path ) ; } $ file = $ path . $ this -> getOption ( 'name' ) . '.json' ; if ( file_exists ( $ file ) ) { $ json = file_get_contents ( $ file ) ; $ saveData = json_decode ( $ json ) ; foreach ( $... | Populates the data array if it can find the settings file . |
55,419 | public function save ( \ Illuminate \ Http \ Request $ input , array $ fields ) { $ data = array ( ) ; $ rules = $ this -> getOption ( 'rules' ) ; foreach ( $ fields as $ name => $ field ) { if ( $ field -> getOption ( 'editable' ) ) { $ data [ $ name ] = $ input -> get ( $ name ) ; if ( $ field -> getOption ( 'type' )... | Attempts to save a settings page . |
55,420 | public function runBeforeSave ( array & $ data ) { $ beforeSave = $ this -> getOption ( 'before_save' ) ; if ( is_callable ( $ beforeSave ) ) { $ bs = $ beforeSave ( $ data ) ; if ( is_string ( $ bs ) ) { return $ bs ; } } return true ; } | Runs the before save method with the supplied data . |
55,421 | public function putToJson ( $ data ) { $ path = $ this -> getStoragePath ( ) ; if ( ! is_writable ( $ path ) ) { throw new \ InvalidArgumentException ( 'The storage_path option in your ' . $ this -> getOption ( 'name' ) . ' settings config is not writable' ) ; } file_put_contents ( $ path . $ this -> getOption ( 'name'... | Puts the data contents into the json file . |
55,422 | public static function open ( $ input , $ rules , $ path , $ random = true ) { return new self ( $ input , $ rules , $ path , $ random ) ; } | Static call Laravel style . Returns a new Multup object allowing for chainable calls . |
55,423 | public function performCountQuery ( QueryBuilder $ countQuery , $ querySql , $ queryBindings , $ page ) { $ model = $ this -> config -> getDataModel ( ) ; $ sql = "SELECT COUNT({$model->getKeyName()}) AS aggregate FROM ({$querySql}) AS agg" ; $ results = $ countQuery -> getConnection ( ) -> select ( $ sql , $ queryBind... | Performs the count query and returns info about the pages . |
55,424 | public function setFilters ( $ filters , QueryBuilder & $ query , QueryBuilder & $ countQuery , & $ selects ) { if ( $ filters && is_array ( $ filters ) ) { foreach ( $ filters as $ filter ) { $ fieldObject = $ this -> fieldFactory -> findFilter ( $ filter [ 'field_name' ] ) ; $ fieldObject -> setFilter ( $ filter ) ; ... | Sets the query filters when getting the rows . |
55,425 | public function parseResults ( $ rows ) { $ results = array ( ) ; foreach ( $ rows as $ item ) { $ arr = array ( ) ; $ this -> parseOnTableColumns ( $ item , $ arr ) ; $ this -> parseComputedColumns ( $ item , $ arr ) ; $ results [ ] = $ arr ; } return $ results ; } | Parses the results of a getRows query and converts it into a manageable array with the proper rendering . |
55,426 | public function parseOnTableColumns ( $ item , array & $ outputRow ) { if ( method_exists ( $ item , 'presenter' ) ) { $ item = $ item -> presenter ( ) ; } $ columns = $ this -> columnFactory -> getColumns ( ) ; $ includedColumns = $ this -> columnFactory -> getIncludedColumns ( $ this -> fieldFactory -> getEditFields ... | Goes through all related columns and sets the proper values for this row . |
55,427 | public function parseComputedColumns ( $ item , array & $ outputRow ) { $ columns = $ this -> columnFactory -> getColumns ( ) ; $ computedColumns = $ this -> columnFactory -> getComputedColumns ( ) ; foreach ( $ computedColumns as $ name => $ column ) { $ outputRow [ $ name ] = array ( 'raw' => $ item -> { $ name } , '... | Goes through all computed columns and sets the proper values for this row . |
55,428 | public function setSort ( $ sort = null ) { $ sort = $ sort && is_array ( $ sort ) ? $ sort : $ this -> config -> getOption ( 'sort' ) ; $ this -> sort = array ( 'field' => isset ( $ sort [ 'field' ] ) ? $ sort [ 'field' ] : $ this -> config -> getDataModel ( ) -> getKeyName ( ) , 'direction' => isset ( $ sort [ 'direc... | Sets up the sort options . |
55,429 | public function setRowsPerPage ( \ Illuminate \ Session \ Store $ session , $ globalPerPage , $ override = null ) { if ( $ override ) { $ perPage = ( int ) $ override ; $ session -> put ( 'administrator_' . $ this -> config -> getOption ( 'name' ) . '_rows_per_page' , $ perPage ) ; } $ perPage = $ session -> get ( 'adm... | Set the number of rows per page for this data table . |
55,430 | public function override ( $ data , $ rules ) { $ this -> setData ( $ data ) ; $ this -> setRules ( $ rules ) ; $ this -> setCustomMessages ( $ this -> overrideCustomMessages ) ; } | Overrides the rules and data . |
55,431 | public function isJoined ( $ query , $ table ) { $ tableFound = false ; $ query = is_a ( $ query , 'Illuminate\Database\Query\Builder' ) ? $ query : $ query -> getQuery ( ) ; if ( $ query -> joins ) { foreach ( $ query -> joins as $ join ) { if ( $ join -> table === $ table ) { return true ; } } } return false ; } | Checks if a table is already joined to a query object . |
55,432 | public function validateArrayWithAllOrNone ( $ attribute , $ value , $ parameters ) { $ missing = 0 ; foreach ( $ parameters as $ key ) { if ( ! isset ( $ value [ $ key ] ) ) { ++ $ missing ; } } return $ missing === count ( $ parameters ) || $ missing === 0 ; } | Validates that an item is an array . |
55,433 | public function getColumnObject ( $ options ) { $ class = $ this -> getColumnClassName ( $ options ) ; return new $ class ( $ this -> validator , $ this -> config , $ this -> db , $ options ) ; } | Creates the Column instance . |
55,434 | public function getColumns ( ) { if ( empty ( $ this -> columns ) ) { foreach ( $ this -> config -> getOption ( 'columns' ) as $ name => $ options ) { $ object = $ this -> make ( $ this -> parseOptions ( $ name , $ options ) ) ; $ this -> columns [ $ object -> getOption ( 'column_name' ) ] = $ object ; } } return $ thi... | Gets the column objects . |
55,435 | public function getColumnOptions ( ) { if ( empty ( $ this -> columnOptions ) ) { foreach ( $ this -> getColumns ( ) as $ column ) { $ this -> columnOptions [ ] = $ column -> getOptions ( ) ; } } return $ this -> columnOptions ; } | Gets the column objects as an integer - indexed array . |
55,436 | public function getRelatedColumns ( ) { if ( empty ( $ this -> relatedColumns ) ) { foreach ( $ this -> getColumns ( ) as $ column ) { if ( $ column -> getOption ( 'is_related' ) ) { $ this -> relatedColumns [ $ column -> getOption ( 'column_name' ) ] = $ column -> getOption ( 'column_name' ) ; } } } return $ this -> r... | Gets the columns that are relationship columns . |
55,437 | public function getComputedColumns ( ) { if ( empty ( $ this -> computedColumns ) ) { foreach ( $ this -> getColumns ( ) as $ column ) { if ( ! $ column -> getOption ( 'is_related' ) && $ column -> getOption ( 'is_computed' ) ) { $ this -> computedColumns [ $ column -> getOption ( 'column_name' ) ] = $ column -> getOpt... | Gets the columns that are computed . |
55,438 | public function build ( ) { parent :: build ( ) ; $ url = $ this -> validator -> getUrlInstance ( ) ; $ route = $ this -> config -> getType ( ) === 'settings' ? 'admin_settings_file_upload' : 'admin_file_upload' ; $ this -> suppliedOptions [ 'upload_url' ] = $ url -> route ( $ route , array ( $ this -> config -> getOpt... | Builds a few basic options |
55,439 | public function doUpload ( ) { $ mimes = $ this -> getOption ( 'mimes' ) ? '|mimes:' . $ this -> getOption ( 'mimes' ) : '' ; $ result = Multup :: open ( 'file' , 'max:' . $ this -> getOption ( 'size_limit' ) * 1000 . $ mimes , $ this -> getOption ( 'location' ) , $ this -> getOption ( 'naming' ) === 'random' ) -> set_... | This static function is used to perform the actual upload and resizing using the Multup class |
55,440 | public function getModel ( $ id = 0 , array $ fields , array $ columns ) { $ originalModel = $ model = $ this -> getDataModel ( ) ; $ model = $ model -> find ( $ id ) ; $ model = $ model ? $ model : $ originalModel ; if ( $ model -> exists ) { $ this -> setExtraModelValues ( $ fields , $ model ) ; } return $ model ; } | Gets a model given an id . |
55,441 | public function setExtraModelValues ( array $ fields , & $ model ) { foreach ( $ fields as $ name => $ field ) { if ( $ field -> getOption ( 'relationship' ) ) { $ this -> setModelRelationship ( $ model , $ field ) ; } if ( $ field -> getOption ( 'setter' ) ) { $ model -> __unset ( $ name ) ; } } } | Fills a model with the data it needs before being sent back to the user . |
55,442 | public function setModelRelationship ( & $ model , Field $ field ) { $ relatedItems = $ this -> getModelRelatedItems ( $ model , $ field ) ; $ name = $ field -> getOption ( 'field_name' ) ; $ multipleValues = $ field -> getOption ( 'multiple_values' ) ; $ nameField = $ field -> getOption ( 'name_field' ) ; $ autocomple... | Fills a model with the necessary relationship values for a field . |
55,443 | public function getModelRelatedItems ( $ model , Field $ field ) { $ name = $ field -> getOption ( 'field_name' ) ; if ( $ field -> getOption ( 'multiple_values' ) ) { if ( $ sortField = $ field -> getOption ( 'sort_field' ) ) { return $ model -> { $ name } ( ) -> orderBy ( $ sortField ) -> get ( ) ; } else { return $ ... | Fills a model with the necessary relationship values . |
55,444 | public function updateModel ( $ model , FieldFactory $ fieldFactory , ActionFactory $ actionFactory ) { $ this -> setDataModel ( $ model -> find ( $ model -> getKey ( ) ) ) ; if ( $ link = $ this -> getModelLink ( ) ) { $ model -> setAttribute ( 'admin_item_link' , $ link ) ; } $ model -> setAttribute ( 'administrator_... | Updates a model with the latest permissions links and fields . |
55,445 | public function fillModel ( & $ model , \ Illuminate \ Http \ Request $ input , array $ fields ) { foreach ( $ fields as $ name => $ field ) { if ( ! $ field -> getOption ( 'external' ) && $ field -> getOption ( 'editable' ) ) { $ field -> fillModel ( $ model , $ input -> get ( $ name , null ) ) ; } elseif ( $ name !==... | Prepare a model for saving given a post input array . |
55,446 | public function getModelValidationRules ( ) { $ optionsRules = $ this -> getOption ( 'rules' ) ; if ( is_array ( $ optionsRules ) ) { return $ optionsRules ; } return $ rules = $ this -> getModelStaticValidationRules ( ) ? : array ( ) ; } | Gets the validation rules for this model . |
55,447 | public function getModelValidationMessages ( ) { $ optionsMessages = $ this -> getOption ( 'messages' ) ; if ( is_array ( $ optionsMessages ) ) { return $ optionsMessages ; } return $ rules = $ this -> getModelStaticValidationMessages ( ) ? : array ( ) ; } | Gets the validation messages for this model . |
55,448 | public function getModelStaticValidationRules ( ) { $ model = $ this -> getDataModel ( ) ; return isset ( $ model :: $ rules ) && is_array ( $ model :: $ rules ) ? $ model :: $ rules : false ; } | Gets the static rules propery for a model if one exists . |
55,449 | public function getModelStaticValidationMessages ( ) { $ model = $ this -> getDataModel ( ) ; return isset ( $ model :: $ messages ) && is_array ( $ model :: $ messages ) ? $ model :: $ messages : false ; } | Gets the static messages propery for a model if one exists . |
55,450 | protected function formatRelationshipInput ( $ value , Field $ field ) { $ value = trim ( $ value ) ; if ( $ field -> getOption ( 'multiple_values' ) ) { $ value = $ value ? explode ( ',' , $ value ) : array ( ) ; } return $ value ; } | Gets the formatted value of a relationship input . |
55,451 | public function saveRelationships ( \ Illuminate \ Http \ Request $ input , & $ model , array $ fields ) { foreach ( $ fields as $ name => $ field ) { if ( $ field -> getOption ( 'external' ) ) { $ field -> fillModel ( $ model , $ input -> get ( $ name , null ) ) ; } } } | After a model has been saved this is called to save the relationships . |
55,452 | public function runQueryFilter ( \ Illuminate \ Database \ Query \ Builder & $ query ) { if ( $ filter = $ this -> getOption ( 'query_filter' ) ) { $ filter ( $ query ) ; } } | Runs a user - supplied query filter if one is supplied . |
55,453 | public function getFilledDataModel ( \ Illuminate \ Http \ Request $ input , array $ fields , $ id = 0 ) { $ model = $ this -> getDataModel ( ) ; if ( $ id ) { $ model = $ model -> find ( $ id ) ; } $ this -> fillModel ( $ model , $ input , $ fields ) ; return $ model ; } | Fetches the data model for a config given a post input array . |
55,454 | public function delete ( $ modelName , $ id ) { $ config = app ( 'itemconfig' ) ; $ actionFactory = app ( 'admin_action_factory' ) ; $ baseModel = $ config -> getDataModel ( ) ; $ model = $ baseModel :: find ( $ id ) ; $ errorResponse = array ( 'success' => false , 'error' => 'There was an error deleting this item. Ple... | POST delete method that accepts data via JSON POST and either saves an old . |
55,455 | public function customModelItemAction ( $ modelName , $ id = null ) { $ config = app ( 'itemconfig' ) ; $ actionFactory = app ( 'admin_action_factory' ) ; $ model = $ config -> getDataModel ( ) ; $ model = $ model :: find ( $ id ) ; $ actionName = $ this -> request -> input ( 'action_name' , false ) ; $ action = $ acti... | POST method for handling custom model item actions . |
55,456 | public function dashboard ( ) { if ( config ( 'administrator.use_dashboard' ) ) { $ this -> layout -> dashboard = true ; $ this -> layout -> content = view ( config ( 'administrator.dashboard_view' ) ) ; return $ this -> layout ; } else { $ configFactory = app ( 'admin_config_factory' ) ; $ home = config ( 'administrat... | Shows the dashboard page . |
55,457 | public function results ( $ modelName ) { $ dataTable = app ( 'admin_datatable' ) ; $ page = $ this -> request -> input ( 'page' , 1 ) ; $ sortOptions = $ this -> request -> input ( 'sortOptions' , array ( ) ) ; $ filters = $ this -> request -> input ( 'filters' , array ( ) ) ; return response ( ) -> json ( $ dataTable... | Gets the database results for the current model . |
55,458 | public function updateOptions ( $ modelName ) { $ fieldFactory = app ( 'admin_field_factory' ) ; $ response = array ( ) ; foreach ( $ this -> request -> input ( 'fields' , array ( ) ) as $ field ) { $ constraints = array_get ( $ field , 'constraints' , array ( ) ) ; $ term = array_get ( $ field , 'term' , array ( ) ) ;... | Gets a list of related items given constraints . |
55,459 | public function fileUpload ( $ modelName , $ fieldName ) { $ fieldFactory = app ( 'admin_field_factory' ) ; $ field = $ fieldFactory -> findField ( $ fieldName ) ; return response ( ) -> JSON ( $ field -> doUpload ( ) ) ; } | The POST method that runs when a user uploads a file on a file field . |
55,460 | public function fileDownload ( ) { if ( $ response = $ this -> session -> get ( 'administrator_download_response' ) ) { $ this -> session -> forget ( 'administrator_download_response' ) ; $ filename = substr ( $ response [ 'headers' ] [ 'content-disposition' ] [ 0 ] , 22 , - 1 ) ; return response ( ) -> download ( $ re... | The GET method that runs when a user needs to download a file . |
55,461 | public function rowsPerPage ( $ modelName ) { $ dataTable = app ( 'admin_datatable' ) ; $ rows = ( int ) $ this -> request -> input ( 'rows' , 20 ) ; $ dataTable -> setRowsPerPage ( app ( 'session.store' ) , 0 , $ rows ) ; return response ( ) -> JSON ( array ( 'success' => true ) ) ; } | The POST method for setting a user s rows per page . |
55,462 | public function page ( $ page ) { $ this -> layout -> page = $ page ; $ this -> layout -> content = view ( $ page ) ; return $ this -> layout ; } | The pages view . |
55,463 | public function settingsCustomAction ( $ settingsName ) { $ config = app ( 'itemconfig' ) ; $ actionFactory = app ( 'admin_action_factory' ) ; $ actionName = $ this -> request -> input ( 'action_name' , false ) ; $ action = $ actionFactory -> getByName ( $ actionName ) ; $ data = $ config -> getDataModel ( ) ; $ result... | POST method for handling custom actions on the settings page . |
55,464 | public function getRelationshipWheres ( $ relationship , $ tableAlias , $ pivotAlias = null , $ pivot = null ) { $ relationshipModel = $ relationship -> getRelated ( ) ; $ query = $ relationship -> getQuery ( ) -> getQuery ( ) ; $ connection = $ query -> getConnection ( ) ; array_splice ( $ query -> wheres , ( method_e... | Sets up the existing relationship wheres . |
55,465 | public function aliasRelationshipWhere ( $ column , $ tableAlias , $ pivotAlias , $ pivot ) { $ split = explode ( '.' , $ column ) ; if ( isset ( $ split [ 1 ] ) ) { if ( $ split [ 0 ] === $ pivot ) { return $ pivotAlias . '.' . $ split [ 1 ] ; } else { return $ tableAlias . '.' . $ split [ 1 ] ; } } else { return $ ta... | Aliases an existing where column . |
55,466 | public function constrainQuery ( EloquentBuilder & $ query , $ relatedModel , $ constraint ) { $ query -> where ( $ this -> getOption ( 'column' ) , '=' , $ constraint ) ; } | Constrains a query by a given set of constraints . |
55,467 | public function validateData ( array $ data , array $ rules , array $ messages ) { if ( $ rules ) { $ this -> customValidator -> setData ( $ data ) ; $ this -> customValidator -> setRules ( $ rules ) ; $ this -> customValidator -> setCustomMessages ( $ messages ) ; if ( $ this -> customValidator -> fails ( ) ) { return... | Validates the supplied data against the options rules . |
55,468 | public function filterQuery ( QueryBuilder & $ query , & $ selects = null ) { $ model = $ this -> config -> getDataModel ( ) ; if ( $ this -> getOption ( 'min_max' ) ) { if ( $ minValue = $ this -> getOption ( 'min_value' ) ) { $ query -> where ( $ model -> getTable ( ) . '.' . $ this -> getOption ( 'field_name' ) , '>... | Filters a query object given . |
55,469 | public function getFilterValue ( $ value ) { if ( ( $ value !== 0 && $ value !== '0' && empty ( $ value ) ) || ( is_string ( $ value ) && trim ( $ value ) === '' ) ) { return false ; } else { return $ value ; } } | Helper function to determine if a filter value should be considered empty or not . |
55,470 | public function setLabelMany ( $ labels , $ many ) { $ labels -> name = __ ( $ many ) ; $ labels -> view_items = __ ( 'View ' . $ many ) ; $ labels -> search_items = __ ( 'Search ' . $ many ) ; $ labels -> not_found = __ ( 'No ' . strtolower ( $ many ) . ' Found' ) ; $ labels -> not_found_in_trash = __ ( 'No ' . strtol... | Set post type plural labels |
55,471 | public function setLabelOne ( $ labels , $ one ) { $ labels -> singular_name = __ ( $ one ) ; $ labels -> add_new = __ ( 'Add ' . $ one ) ; $ labels -> add_new_item = __ ( 'Add New ' . $ one ) ; $ labels -> edit_item = __ ( 'Edit ' . $ one ) ; $ labels -> new_item = __ ( 'New ' . $ one ) ; $ labels -> view_item = __ ( ... | Set post type singular labels |
55,472 | public function setLabelIcon ( $ type , $ config ) { global $ menu ; switch ( $ type ) { case 'post' : $ position = 5 ; break ; case 'page' : $ position = 20 ; break ; } if ( $ this -> isArrayValueSet ( 2 , $ config ) ) { $ icon = $ config [ 2 ] ; if ( strpos ( $ icon , 'dashicons-' ) === false ) { $ icon = 'dashicons-... | Set post type icon |
55,473 | public function isArrayValueSet ( $ pos , $ arr ) { if ( is_array ( $ arr ) && array_key_exists ( $ pos , $ arr ) && ! empty ( $ arr [ $ pos ] ) ) { return true ; } } | Determine if array value has been set |
55,474 | protected function aliasUserRoles ( $ args ) { if ( in_array ( 'all' , $ args ) ) { $ args = $ this -> getUserRoles ( ) ; } if ( in_array ( 'all-not-admin' , $ args ) ) { $ args = $ this -> getUserRoles ( false ) ; } $ args = preg_replace ( '/\badmin\b/' , 'administrator' , $ args ) ; return $ args ; } | Alias user roles all and all - not - admin Replace short - hand admin with administrator |
55,475 | public static function getUserRoles ( $ incl_admin = true ) { $ wp_roles = new \ WP_Roles ( ) ; $ wp_roles = $ wp_roles -> get_names ( ) ; if ( ! $ incl_admin ) { unset ( $ wp_roles [ 'administrator' ] ) ; } $ roles = [ ] ; foreach ( $ wp_roles as $ key => $ value ) { $ roles [ ] = $ key ; } return $ roles ; } | Get all user roles from WordPress |
55,476 | protected function processDefinition ( $ locale , array $ definition ) { $ definition [ 'locale' ] = $ locale ; if ( $ definition [ 'locale' ] != 'en' ) { $ definitions = $ this -> getDefinitions ( ) ; $ definition += $ definitions [ 'en' ] ; } return $ definition ; } | Processes the number format definition for the provided locale . |
55,477 | protected function getNumberFormat ( $ locale ) { if ( ! isset ( $ this -> numberFormats [ $ locale ] ) ) { $ this -> numberFormats [ $ locale ] = $ this -> numberFormatRepository -> get ( $ locale ) ; } return $ this -> numberFormats [ $ locale ] ; } | Gets the number format for the provided locale . |
55,478 | protected function getCurrency ( $ currencyCode , $ locale ) { if ( ! isset ( $ this -> currencies [ $ currencyCode ] [ $ locale ] ) ) { try { $ currency = $ this -> currencyRepository -> get ( $ currencyCode , $ locale ) ; } catch ( UnknownCurrencyException $ e ) { $ currency = new Currency ( [ 'currency_code' => $ cu... | Gets the currency for the provided currency code and locale . |
55,479 | protected function formatNumber ( $ number , NumberFormat $ numberFormat , array $ options = [ ] ) { $ parsedPattern = $ this -> getParsedPattern ( $ numberFormat , $ options [ 'style' ] ) ; if ( is_int ( $ options [ 'rounding_mode' ] ) ) { $ number = Calculator :: round ( $ number , $ options [ 'maximum_fraction_digit... | Formats the number according to the number format . |
55,480 | protected function localizeNumber ( $ number , NumberFormat $ numberFormat ) { $ numberingSystem = $ numberFormat -> getNumberingSystem ( ) ; if ( isset ( $ this -> digits [ $ numberingSystem ] ) ) { $ number = strtr ( $ number , $ this -> digits [ $ numberingSystem ] ) ; } $ replacements = [ '.' => $ numberFormat -> g... | Localizes the number according to the number format . |
55,481 | protected function parseNumber ( $ number , NumberFormat $ numberFormat ) { $ replacements = [ $ numberFormat -> getGroupingSeparator ( ) => '' , $ numberFormat -> getDecimalSeparator ( ) => '.' , $ numberFormat -> getPlusSign ( ) => '+' , $ numberFormat -> getMinusSign ( ) => '-' , $ numberFormat -> getPercentSign ( )... | Parses the number according to the number format . |
55,482 | protected function getParsedPattern ( NumberFormat $ numberFormat , $ style ) { $ locale = $ numberFormat -> getLocale ( ) ; if ( ! isset ( $ this -> parsedPatterns [ $ locale ] [ $ style ] ) ) { $ availablePatterns = $ this -> getAvailablePatterns ( $ numberFormat ) ; if ( ! isset ( $ availablePatterns [ $ style ] ) )... | Gets the pattern for the provided number format . |
55,483 | public static function add ( $ first_number , $ second_number , $ scale = 6 ) { self :: assertNumberFormat ( $ first_number ) ; self :: assertNumberFormat ( $ second_number ) ; $ result = bcadd ( $ first_number , $ second_number , $ scale ) ; return self :: trim ( $ result ) ; } | Adds the second number to the first number . |
55,484 | public static function subtract ( $ first_number , $ second_number , $ scale = 6 ) { self :: assertNumberFormat ( $ first_number ) ; self :: assertNumberFormat ( $ second_number ) ; $ result = bcsub ( $ first_number , $ second_number , $ scale ) ; return self :: trim ( $ result ) ; } | Subtracts the second number from the first number . |
55,485 | public static function multiply ( $ first_number , $ second_number , $ scale = 6 ) { self :: assertNumberFormat ( $ first_number ) ; self :: assertNumberFormat ( $ second_number ) ; $ result = bcmul ( $ first_number , $ second_number , $ scale ) ; return self :: trim ( $ result ) ; } | Multiplies the first number by the second number . |
55,486 | public static function divide ( $ first_number , $ second_number , $ scale = 6 ) { self :: assertNumberFormat ( $ first_number ) ; self :: assertNumberFormat ( $ second_number ) ; $ result = bcdiv ( $ first_number , $ second_number , $ scale ) ; return self :: trim ( $ result ) ; } | Divides the first number by the second number . |
55,487 | public static function ceil ( $ number ) { if ( self :: compare ( $ number , 0 ) == 1 ) { $ result = bcadd ( $ number , '1' , 0 ) ; } else { $ result = bcadd ( $ number , '0' , 0 ) ; } return $ result ; } | Calculates the next highest whole value of a number . |
55,488 | public static function floor ( $ number ) { if ( self :: compare ( $ number , 0 ) == 1 ) { $ result = bcadd ( $ number , '0' , 0 ) ; } else { $ result = bcadd ( $ number , '-1' , 0 ) ; } return $ result ; } | Calculates the next lowest whole value of a number . |
55,489 | public static function round ( $ number , $ precision = 0 , $ mode = PHP_ROUND_HALF_UP ) { self :: assertNumberFormat ( $ number ) ; if ( ! is_numeric ( $ precision ) || $ precision < 0 ) { throw new \ InvalidArgumentException ( 'The provided precision should be a positive number' ) ; } $ rounding_increment = bcdiv ( '... | Rounds the given number . |
55,490 | public static function compare ( $ first_number , $ second_number , $ scale = 6 ) { self :: assertNumberFormat ( $ first_number ) ; self :: assertNumberFormat ( $ second_number ) ; return bccomp ( $ first_number , $ second_number , $ scale ) ; } | Compares the first number to the second number . |
55,491 | public static function trim ( $ number ) { if ( strpos ( $ number , '.' ) != false ) { $ number = rtrim ( $ number , '0' ) ; $ number = rtrim ( $ number , '.' ) ; } return $ number ; } | Trims the given number . |
55,492 | public static function assertNumberFormat ( $ number ) { if ( is_float ( $ number ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The provided value "%s" must be a string, not a float.' , $ number ) ) ; } if ( ! is_numeric ( $ number ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The provided value "%s... | Assert that the given number is a numeric string value . |
55,493 | public function sendEstimate ( $ deliveryMethodOrOptions = SendInvoiceOptions :: METHOD_EMAIL ) { if ( is_string ( $ deliveryMethodOrOptions ) ) { $ options = new SendInvoiceOptions ( $ deliveryMethodOrOptions ) ; } else { $ options = $ deliveryMethodOrOptions ; } unset ( $ deliveryMethodOrOptions ) ; if ( ! $ options ... | Instruct Moneybird to send the estimate to the contact . |
55,494 | public function send ( ) { $ aReminder = $ this -> json ( ) ; $ aReminder = json_decode ( $ aReminder , true ) ; $ aReminder [ 'sales_invoice_ids' ] = array_map ( function ( $ salesInvoice ) { if ( is_object ( $ salesInvoice ) ) { return $ salesInvoice -> id ; } else { return $ salesInvoice ; } } , $ this -> sales_invo... | Pushes the reminder . |
55,495 | public function download ( ) { $ connection = $ this -> connection ( ) ; $ client = $ connection -> connect ( ) ; $ headers = [ 'Accept' => 'application/pdf' , 'Content-Type' => 'application/pdf' , 'Authorization' => 'Bearer ' . $ connection -> getAccessToken ( ) , ] ; $ endpoint = 'https://moneybird.com/' . $ connecti... | Download invoice as PDF . |
55,496 | public function findByInvoiceId ( $ invoiceId ) { $ result = $ this -> connection ( ) -> get ( $ this -> getEndpoint ( ) . '/find_by_invoice_id/' . urlencode ( $ invoiceId ) ) ; return $ this -> makeFromResponse ( $ result ) ; } | Find SalesInvoice by invoice_id . |
55,497 | public function registerPayment ( SalesInvoicePayment $ salesInvoicePayment ) { if ( ! isset ( $ salesInvoicePayment -> payment_date ) ) { throw new ApiException ( 'Required [payment_date] is missing' ) ; } if ( ! isset ( $ salesInvoicePayment -> price ) ) { throw new ApiException ( 'Required [price] is missing' ) ; } ... | Register a payment for the current invoice . |
55,498 | public function deletePayment ( SalesInvoicePayment $ salesInvoicePayment ) { if ( ! isset ( $ salesInvoicePayment -> id ) ) { throw new ApiException ( 'Required [id] is missing' ) ; } $ this -> connection ( ) -> delete ( $ this -> endpoint . '/' . $ this -> id . '/payments/' . $ salesInvoicePayment -> id ) ; return $ ... | Delete a payment for the current invoice . |
55,499 | public function addNote ( Note $ note ) { $ this -> connection ( ) -> post ( $ this -> endpoint . '/' . $ this -> id . '/notes' , $ note -> jsonWithNamespace ( ) ) ; return $ this ; } | Add a note to the current invoice . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.