idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
22,200
public function render ( ) { $ data = array_merge ( $ this -> data , [ 'attributes' => $ this -> formatAttributes ( ) ] ) ; return view ( $ this -> view , $ data ) -> render ( ) ; }
Render Tab .
22,201
protected function inAllowedMethods ( $ method ) { $ allowedMethods = collect ( config ( 'admin.operation_log.allowed_methods' ) ) -> filter ( ) ; if ( $ allowedMethods -> isEmpty ( ) ) { return true ; } return $ allowedMethods -> map ( function ( $ method ) { return strtoupper ( $ method ) ; } ) -> contains ( $ method...
Whether requests using this method are allowed to be logged .
22,202
public function resolve ( $ driver ) { if ( $ driver instanceof Grid \ Exporters \ AbstractExporter ) { return $ driver -> setGrid ( $ this -> grid ) ; } return $ this -> getExporter ( $ driver ) ; }
Resolve export driver .
22,203
protected function getExporter ( $ driver ) { if ( ! array_key_exists ( $ driver , static :: $ drivers ) ) { return $ this -> getDefaultExporter ( ) ; } return new static :: $ drivers [ $ driver ] ( $ this -> grid ) ; }
Get export driver .
22,204
protected function listAdminCommands ( ) { $ commands = collect ( Artisan :: all ( ) ) -> mapWithKeys ( function ( $ command , $ key ) { if ( Str :: startsWith ( $ key , 'admin:' ) ) { return [ $ key => $ command ] ; } return [ ] ; } ) -> toArray ( ) ; $ width = $ this -> getColumnWidth ( $ commands ) ; foreach ( $ com...
List all admin commands .
22,205
protected function getTableDataArrayAsString ( $ table , $ exceptFields = [ ] ) { $ fields = \ DB :: getSchemaBuilder ( ) -> getColumnListing ( $ table ) ; $ fields = array_diff ( $ fields , $ exceptFields ) ; $ array = \ DB :: table ( $ table ) -> get ( $ fields ) -> map ( function ( $ item ) { return ( array ) $ item...
Get data array from table as string result var_export .
22,206
protected function varExport ( $ var , $ indent = '' ) { switch ( gettype ( $ var ) ) { case 'string' : return '"' . addcslashes ( $ var , "\\\$\"\r\n\t\v\f" ) . '"' ; case 'array' : $ indexed = array_keys ( $ var ) === range ( 0 , count ( $ var ) - 1 ) ; $ r = [ ] ; foreach ( $ var as $ key => $ value ) { $ r [ ] = "$...
Custom var_export for correct work with \ r \ n .
22,207
public function render ( ) { $ relation = $ this -> model -> { $ this -> name } ( ) ; $ renderable = $ this -> getNullRenderable ( ) ; if ( $ relation instanceof HasOne || $ relation instanceof BelongsTo || $ relation instanceof MorphOne ) { $ model = $ this -> model -> { $ this -> name } ; if ( ! $ model instanceof Mo...
Render this relation panel .
22,208
public function setGrid ( Grid $ grid ) { $ this -> grid = $ grid ; $ this -> setModel ( $ grid -> model ( ) -> eloquent ( ) ) ; }
Set grid instance for column .
22,209
public function setRelation ( $ relation , $ relationColumn = null ) { $ this -> relation = $ relation ; $ this -> relationColumn = $ relationColumn ; return $ this ; }
Set relation .
22,210
public function displayUsing ( $ abstract , $ arguments = [ ] ) { $ grid = $ this -> grid ; $ column = $ this ; return $ this -> display ( function ( $ value ) use ( $ grid , $ column , $ abstract , $ arguments ) { $ displayer = new $ abstract ( $ value , $ grid , $ column , $ this ) ; return $ displayer -> display ( ....
Display using display abstract .
22,211
public function view ( $ view ) { return $ this -> display ( function ( $ value ) use ( $ view ) { $ model = $ this ; return view ( $ view , compact ( 'model' , 'value' ) ) -> render ( ) ; } ) ; }
Render this column with the given view .
22,212
public function totalRow ( $ display = null ) { $ this -> grid -> addTotalRow ( $ this -> name , $ display ) ; return $ this ; }
Add column to total - row .
22,213
protected function htmlEntityEncode ( $ item ) { if ( is_array ( $ item ) ) { array_walk_recursive ( $ item , function ( & $ value ) { $ value = htmlentities ( $ value ) ; } ) ; } else { $ item = htmlentities ( $ item ) ; } return $ item ; }
Convert characters to HTML entities recursively .
22,214
public function sorter ( ) { if ( ! $ this -> sortable ) { return '' ; } $ icon = 'fa-sort' ; $ type = 'desc' ; if ( $ this -> isSorted ( ) ) { $ type = $ this -> sort [ 'type' ] == 'desc' ? 'asc' : 'desc' ; $ icon .= "-amount-{$this->sort['type']}" ; } $ sort = [ 'column' => $ this -> name , 'type' => $ type ] ; if ( ...
Create the column sorter .
22,215
protected function isSorted ( ) { $ this -> sort = app ( 'request' ) -> get ( $ this -> grid -> model ( ) -> getSortName ( ) ) ; if ( empty ( $ this -> sort ) ) { return false ; } return isset ( $ this -> sort [ 'column' ] ) && $ this -> sort [ 'column' ] == $ this -> name ; }
Determine if this column is currently sorted .
22,216
protected function resolveDisplayer ( $ abstract , $ arguments ) { if ( array_key_exists ( $ abstract , static :: $ displayers ) ) { return $ this -> callBuiltinDisplayer ( static :: $ displayers [ $ abstract ] , $ arguments ) ; } return $ this -> callSupportDisplayer ( $ abstract , $ arguments ) ; }
Find a displayer to display column .
22,217
public function navbar ( Closure $ builder = null ) { if ( is_null ( $ builder ) ) { return $ this -> getNavbar ( ) ; } call_user_func ( $ builder , $ this -> getNavbar ( ) ) ; }
Set navbar .
22,218
public function bootstrap ( ) { $ this -> fireBootingCallbacks ( ) ; Form :: registerBuiltinFields ( ) ; Grid :: registerColumnDisplayer ( ) ; Grid \ Filter :: registerFilters ( ) ; require config ( 'admin.bootstrap' , admin_path ( 'bootstrap.php' ) ) ; $ assets = Form :: collectFieldAssets ( ) ; self :: css ( $ assets...
Bootstrap the admin application .
22,219
public function header ( Closure $ closure = null ) { if ( ! $ closure ) { return $ this -> header ; } $ this -> header = $ closure ; return $ this ; }
Set grid header .
22,220
public function getLogin ( ) { if ( $ this -> guard ( ) -> check ( ) ) { return redirect ( $ this -> redirectPath ( ) ) ; } return view ( $ this -> loginView ) ; }
Show the login page .
22,221
public function getLogout ( Request $ request ) { $ this -> guard ( ) -> logout ( ) ; $ request -> session ( ) -> invalidate ( ) ; return redirect ( config ( 'admin.route.prefix' ) ) ; }
User logout .
22,222
public function getSetting ( Content $ content ) { $ form = $ this -> settingForm ( ) ; $ form -> tools ( function ( Form \ Tools $ tools ) { $ tools -> disableList ( ) ; } ) ; return $ content -> header ( trans ( 'admin.user_setting' ) ) -> body ( $ form -> edit ( Admin :: user ( ) -> id ) ) ; }
User setting page .
22,223
protected function redirectPath ( ) { if ( method_exists ( $ this , 'redirectTo' ) ) { return $ this -> redirectTo ( ) ; } return property_exists ( $ this , 'redirectTo' ) ? $ this -> redirectTo : config ( 'admin.route.prefix' ) ; }
Get the post login redirect path .
22,224
public function row ( $ content ) { if ( ! $ content instanceof \ Closure ) { $ row = new Row ( $ content ) ; } else { $ row = new Row ( ) ; call_user_func ( $ content , $ row ) ; } ob_start ( ) ; $ row -> build ( ) ; $ contents = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ this -> append ( $ contents ) ; }
Add a row for column .
22,225
public function build ( ) { $ this -> startColumn ( ) ; foreach ( $ this -> contents as $ content ) { if ( $ content instanceof Renderable || $ content instanceof Grid ) { echo $ content -> render ( ) ; } else { echo ( string ) $ content ; } } $ this -> endColumn ( ) ; }
Build column html .
22,226
public static function deny ( $ roles ) { if ( static :: isAdministrator ( ) ) { return true ; } if ( Auth :: guard ( 'admin' ) -> user ( ) -> inRoles ( $ roles ) ) { static :: error ( ) ; } }
Roles denied to access .
22,227
protected function formatName ( $ column ) { $ columns = explode ( '.' , $ column ) ; if ( count ( $ columns ) == 1 ) { $ name = $ columns [ 0 ] ; } else { $ name = array_shift ( $ columns ) ; foreach ( $ columns as $ column ) { $ name .= "[$column]" ; } } $ parenName = $ this -> parent -> getName ( ) ; return $ parenN...
Format name .
22,228
protected function buildCondition ( ) { $ column = explode ( '.' , $ this -> column ) ; if ( count ( $ column ) == 1 ) { return [ $ this -> query => func_get_args ( ) ] ; } return $ this -> buildRelationQuery ( ... func_get_args ( ) ) ; }
Build conditions of filter .
22,229
protected function buildRelationQuery ( ) { $ args = func_get_args ( ) ; list ( $ relation , $ args [ 0 ] ) = explode ( '.' , $ this -> column ) ; return [ 'whereHas' => [ $ relation , function ( $ relation ) use ( $ args ) { call_user_func_array ( [ $ relation , $ this -> query ] , $ args ) ; } ] ] ; }
Build query condition of model relation .
22,230
protected function variables ( ) { return array_merge ( [ 'id' => $ this -> id , 'name' => $ this -> formatName ( $ this -> column ) , 'label' => $ this -> label , 'value' => $ this -> value ? : $ this -> defaultValue , 'presenter' => $ this -> presenter ( ) , ] , $ this -> presenter ( ) -> variables ( ) ) ; }
Variables for filter view .
22,231
protected function initPaginator ( ) { $ this -> paginator = $ this -> grid -> model ( ) -> eloquent ( ) ; if ( $ this -> paginator instanceof LengthAwarePaginator ) { $ this -> paginator -> appends ( Input :: all ( ) ) ; } }
Initialize work for Paginator .
22,232
protected function paginationRanger ( ) { $ parameters = [ 'first' => $ this -> paginator -> firstItem ( ) , 'last' => $ this -> paginator -> lastItem ( ) , 'total' => $ this -> paginator -> total ( ) , ] ; $ parameters = collect ( $ parameters ) -> flatMap ( function ( $ parameter , $ key ) { return [ $ key => "<b>$pa...
Get range infomation of paginator .
22,233
protected function total ( $ column , $ display ) { if ( ! is_callable ( $ display ) && ! is_null ( $ display ) ) { return $ display ; } $ sum = $ this -> query -> sum ( $ column ) ; if ( is_callable ( $ display ) ) { return call_user_func ( $ display , $ sum ) ; } return $ sum ; }
Get total value of current column .
22,234
public function render ( ) { $ columns = $ this -> getGrid ( ) -> columns ( ) -> flatMap ( function ( Column $ column ) { $ name = $ column -> getName ( ) ; $ total = ( $ display = Arr :: get ( $ this -> columns , $ name ) ) ? $ this -> total ( $ name , $ display ) : '' ; return [ $ name => $ total ] ; } ) -> toArray (...
Render total - row .
22,235
public function move ( $ directory , $ name = null ) { $ this -> dir ( $ directory ) ; $ this -> name ( $ name ) ; return $ this ; }
Specify the directory and name for upload file .
22,236
protected function getStoreName ( UploadedFile $ file ) { if ( $ this -> useUniqueName ) { return $ this -> generateUniqueName ( $ file ) ; } if ( $ this -> useSequenceName ) { return $ this -> generateSequenceName ( $ file ) ; } if ( $ this -> name instanceof \ Closure ) { return $ this -> name -> call ( $ this , $ fi...
Get store name of upload file .
22,237
public function getDirectory ( ) { if ( $ this -> directory instanceof \ Closure ) { return call_user_func ( $ this -> directory , $ this -> form ) ; } return $ this -> directory ? : $ this -> defaultDirectory ( ) ; }
Get directory for store file .
22,238
public function renameIfExists ( UploadedFile $ file ) { if ( $ this -> storage -> exists ( "{$this->getDirectory()}/$this->name" ) ) { $ this -> name = $ this -> generateUniqueName ( $ file ) ; } }
If name already exists rename it .
22,239
protected function generateSequenceName ( UploadedFile $ file ) { $ index = 1 ; $ extension = $ file -> getClientOriginalExtension ( ) ; $ originalName = $ file -> getClientOriginalName ( ) ; $ newName = $ originalName . '_' . $ index . '.' . $ extension ; while ( $ this -> storage -> exists ( "{$this->getDirectory()}/...
Generate a sequence name for uploaded file .
22,240
public function allNodes ( ) { $ orderColumn = DB :: getQueryGrammar ( ) -> wrap ( $ this -> orderColumn ) ; $ byOrder = $ orderColumn . ' = 0,' . $ orderColumn ; $ self = new static ( ) ; if ( $ this -> queryCallback instanceof \ Closure ) { $ self = call_user_func ( $ this -> queryCallback , $ self ) ; } return $ sel...
Get all elements .
22,241
public static function saveOrder ( $ tree = [ ] , $ parentId = 0 ) { if ( empty ( static :: $ branchOrder ) ) { static :: setBranchOrder ( $ tree ) ; } foreach ( $ tree as $ branch ) { $ node = static :: find ( $ branch [ 'id' ] ) ; $ node -> { $ node -> getParentColumn ( ) } = $ parentId ; $ node -> { $ node -> getOrd...
Save tree order from a tree like array .
22,242
public static function selectOptions ( \ Closure $ closure = null , $ rootText = 'Root' ) { $ options = ( new static ( ) ) -> withQuery ( $ closure ) -> buildSelectOptions ( ) ; return collect ( $ options ) -> prepend ( $ rootText , 0 ) -> all ( ) ; }
Get options for Select field in form .
22,243
protected function buildSelectOptions ( array $ nodes = [ ] , $ parentId = 0 , $ prefix = '' ) { $ prefix = $ prefix ? : str_repeat ( '&nbsp;' , 6 ) ; $ options = [ ] ; if ( empty ( $ nodes ) ) { $ nodes = $ this -> allNodes ( ) ; } foreach ( $ nodes as $ node ) { $ node [ $ this -> titleColumn ] = $ prefix . '&nbsp;' ...
Build options of select field in form .
22,244
public function callInterventionMethods ( $ target ) { if ( ! empty ( $ this -> interventionCalls ) ) { $ image = ImageManagerStatic :: make ( $ target ) ; foreach ( $ this -> interventionCalls as $ call ) { call_user_func_array ( [ $ image , $ call [ 'method' ] ] , $ call [ 'arguments' ] ) -> save ( $ target ) ; } } r...
Execute Intervention calls .
22,245
protected function getEditPath ( ) { $ key = $ this -> panel -> getParent ( ) -> getModel ( ) -> getKey ( ) ; return $ this -> getListPath ( ) . '/' . $ key . '/edit' ; }
Get request path for edit .
22,246
protected function renderDelete ( ) { $ trans = [ 'delete_confirm' => trans ( 'admin.delete_confirm' ) , 'confirm' => trans ( 'admin.confirm' ) , 'cancel' => trans ( 'admin.cancel' ) , 'delete' => trans ( 'admin.delete' ) , ] ; $ class = uniqid ( ) ; $ script = <<<SCRIPT$('.{$class}-delete').unbind('click').click(func...
Render delete tool .
22,247
public function render ( ) { $ output = $ this -> renderCustomTools ( $ this -> prepends ) ; foreach ( $ this -> tools as $ tool ) { $ renderMethod = 'render' . ucfirst ( $ tool ) ; $ output .= $ this -> $ renderMethod ( ) ; } return $ output . $ this -> renderCustomTools ( $ this -> appends ) ; }
Render tools .
22,248
protected function formatValidationAttribute ( $ input , $ label , $ column ) { $ new = $ attributes = [ ] ; if ( is_array ( $ column ) ) { foreach ( $ column as $ index => $ col ) { $ new [ $ col . $ index ] = $ col ; } } foreach ( array_keys ( Arr :: dot ( $ input ) ) as $ key ) { if ( is_string ( $ column ) ) { if (...
Format validation attributes .
22,249
protected function getKeyName ( ) { if ( is_null ( $ this -> form ) ) { return ; } return $ this -> form -> model ( ) -> { $ this -> relationName } ( ) -> getRelated ( ) -> getKeyName ( ) ; }
Get the HasMany relation key name .
22,250
protected function buildRelatedForms ( ) { if ( is_null ( $ this -> form ) ) { return [ ] ; } $ model = $ this -> form -> model ( ) ; $ relation = call_user_func ( [ $ model , $ this -> relationName ] ) ; if ( ! $ relation instanceof Relation && ! $ relation instanceof MorphMany ) { throw new \ Exception ( 'hasMany fie...
Build Nested form for related data .
22,251
protected function setupScript ( $ script ) { $ method = 'setupScriptFor' . ucfirst ( $ this -> viewMode ) . 'View' ; call_user_func ( [ $ this , $ method ] , $ script ) ; }
Setup script for this field in different view mode .
22,252
protected function renderTable ( ) { $ headers = [ ] ; $ fields = [ ] ; $ hidden = [ ] ; $ scripts = [ ] ; foreach ( $ this -> buildNestedForm ( $ this -> column , $ this -> builder ) -> fields ( ) as $ field ) { if ( is_a ( $ field , Hidden :: class ) ) { $ hidden [ ] = $ field -> render ( ) ; } else { $ field -> setL...
Render the HasMany field for table style .
22,253
protected function callHooks ( $ name ) { $ hooks = Arr :: get ( $ this -> hooks , $ name , [ ] ) ; foreach ( $ hooks as $ func ) { if ( ! $ func instanceof Closure ) { continue ; } $ response = call_user_func ( $ func , $ this ) ; if ( $ response instanceof Response ) { return $ response ; } } }
Call hooks by giving name .
22,254
protected function handleExportRequest ( $ forceExport = false ) { if ( ! $ scope = request ( Exporter :: $ queryName ) ) { return ; } if ( ob_get_length ( ) ) { ob_end_clean ( ) ; } $ this -> model ( ) -> usePaginate ( false ) ; if ( $ this -> builder ) { call_user_func ( $ this -> builder , $ this ) ; $ this -> getEx...
Handle export request .
22,255
public function option ( $ key , $ value = null ) { if ( is_null ( $ value ) ) { return $ this -> options [ $ key ] ; } $ this -> options [ $ key ] = $ value ; return $ this ; }
Get or set option for grid .
22,256
public function columns ( $ columns = [ ] ) { if ( func_num_args ( ) == 0 ) { return $ this -> columns ; } if ( func_num_args ( ) == 1 && is_array ( $ columns ) ) { foreach ( $ columns as $ column => $ label ) { $ this -> column ( $ column , $ label ) ; } return ; } foreach ( func_get_args ( ) as $ column ) { $ this ->...
Batch add column to grid .
22,257
public function visibleColumns ( ) { $ visible = array_filter ( explode ( ',' , request ( Tools \ ColumnSelector :: SELECT_COLUMN_NAME ) ) ) ; if ( empty ( $ visible ) ) { return $ this -> columns ; } array_push ( $ visible , '__row_selector__' , '__actions__' ) ; return $ this -> columns -> filter ( function ( Column ...
Get all visible column instances .
22,258
public function visibleColumnNames ( ) { $ visible = array_filter ( explode ( ',' , request ( Tools \ ColumnSelector :: SELECT_COLUMN_NAME ) ) ) ; if ( empty ( $ visible ) ) { return $ this -> columnNames ; } array_push ( $ visible , '__row_selector__' , '__actions__' ) ; return collect ( $ this -> columnNames ) -> fil...
Get all visible column names .
22,259
protected function prependColumn ( $ column = '' , $ label = '' ) { $ column = new Column ( $ column , $ label ) ; $ column -> setGrid ( $ this ) ; return tap ( $ column , function ( $ value ) { $ this -> columns -> prepend ( $ value ) ; } ) ; }
Prepend column to grid .
22,260
public function disablePagination ( bool $ disable = true ) { $ this -> model -> usePaginate ( ! $ disable ) ; return $ this -> option ( 'show_pagination' , ! $ disable ) ; }
Disable grid pagination .
22,261
public function actions ( $ actions ) { if ( $ actions instanceof Closure ) { $ this -> actionsCallback = $ actions ; } if ( is_string ( $ actions ) && is_subclass_of ( $ actions , Displayers \ Actions :: class ) ) { $ this -> actionsClass = $ actions ; } return $ this ; }
Set grid action callback .
22,262
public function disableRowSelector ( bool $ disable = true ) { $ this -> tools -> disableBatchActions ( $ disable ) ; return $ this -> option ( 'show_row_selector' , ! $ disable ) ; }
Disable row selector .
22,263
protected function buildRows ( array $ data ) { $ this -> rows = collect ( $ data ) -> map ( function ( $ model , $ number ) { return new Row ( $ number , $ model ) ; } ) ; if ( $ this -> rowsCallback ) { $ this -> rows -> map ( $ this -> rowsCallback ) ; } }
Build the grid rows .
22,264
public function getCreateUrl ( ) { $ queryString = '' ; if ( $ constraints = $ this -> model ( ) -> getConstraints ( ) ) { $ queryString = http_build_query ( $ constraints ) ; } return sprintf ( '%s/create%s' , $ this -> resource ( ) , $ queryString ? ( '?' . $ queryString ) : '' ) ; }
Get create url .
22,265
public function resource ( $ path = null ) { if ( ! empty ( $ path ) ) { $ this -> resourcePath = $ path ; return $ this ; } if ( ! empty ( $ this -> resourcePath ) ) { return $ this -> resourcePath ; } return app ( 'request' ) -> getPathInfo ( ) ; }
Get current resource uri .
22,266
protected function handleGetMutatorColumn ( $ method , $ label ) { if ( $ this -> model ( ) -> eloquent ( ) -> hasGetMutator ( $ method ) ) { return $ this -> addColumn ( $ method , $ label ) ; } return false ; }
Handle get mutator column for grid .
22,267
public function setView ( $ view , $ variables = [ ] ) { if ( ! empty ( $ variables ) ) { $ this -> with ( $ variables ) ; } $ this -> view = $ view ; }
Set a view to render .
22,268
public function render ( ) { $ this -> handleExportRequest ( true ) ; try { $ this -> build ( ) ; } catch ( \ Exception $ e ) { return Handler :: renderException ( $ e ) ; } return view ( $ this -> view , $ this -> variables ( ) ) -> render ( ) ; }
Get the string contents of the grid view .
22,269
public static function getQueryHash ( \ Closure $ closure , $ label = '' ) { $ reflection = new \ ReflectionFunction ( $ closure ) ; return md5 ( $ reflection -> getFileName ( ) . $ reflection -> getStartLine ( ) . $ reflection -> getEndLine ( ) . $ label ) ; }
Get the hash string of query closure .
22,270
public function setName ( $ name ) { $ this -> name = $ name ; $ this -> model ( ) -> setPerPageName ( "{$name}_{$this->model()->getPerPageName()}" ) ; $ this -> getFilter ( ) -> setName ( $ name ) ; return $ this ; }
Set name to grid .
22,271
public function fields ( array $ fields = [ ] ) { if ( ! Arr :: isAssoc ( $ fields ) ) { $ fields = array_combine ( $ fields , $ fields ) ; } foreach ( $ fields as $ field => $ label ) { $ this -> field ( $ field , $ label ) ; } return $ this ; }
Add multiple fields .
22,272
public function relation ( $ name , $ label , $ builder = null ) { if ( is_null ( $ builder ) ) { $ builder = $ label ; $ label = '' ; } return $ this -> addRelation ( $ name , $ builder , $ label ) ; }
Add a relation to show .
22,273
protected function addField ( $ name , $ label = '' ) { $ field = new Field ( $ name , $ label ) ; $ field -> setParent ( $ this ) ; $ this -> overwriteExistingField ( $ name ) ; return tap ( $ field , function ( $ field ) { $ this -> fields -> push ( $ field ) ; } ) ; }
Add a model field to show .
22,274
protected function addRelation ( $ name , $ builder , $ label = '' ) { $ relation = new Relation ( $ name , $ builder , $ label ) ; $ relation -> setParent ( $ this ) ; $ this -> overwriteExistingRelation ( $ name ) ; return tap ( $ relation , function ( $ relation ) { $ this -> relations -> push ( $ relation ) ; } ) ;...
Add a relation panel to show .
22,275
protected function overwriteExistingField ( $ name ) { if ( $ this -> fields -> isEmpty ( ) ) { return ; } $ this -> fields = $ this -> fields -> filter ( function ( Field $ field ) use ( $ name ) { return $ field -> getName ( ) != $ name ; } ) ; }
Overwrite existing field .
22,276
protected function overwriteExistingRelation ( $ name ) { if ( $ this -> relations -> isEmpty ( ) ) { return ; } $ this -> relations = $ this -> relations -> filter ( function ( Relation $ relation ) use ( $ name ) { return $ relation -> getName ( ) != $ name ; } ) ; }
Overwrite existing relation .
22,277
protected function handleGetMutatorField ( $ method , $ label ) { if ( is_null ( $ this -> model ) ) { return false ; } if ( $ this -> model -> hasGetMutator ( $ method ) ) { return $ this -> addField ( $ method , $ label ) ; } return false ; }
Handle the get mutator field .
22,278
protected function handleRelationField ( $ method , $ arguments ) { if ( ! method_exists ( $ this -> model , $ method ) ) { return false ; } if ( ! ( $ relation = $ this -> model -> $ method ( ) ) instanceof EloquentRelation ) { return false ; } if ( $ relation instanceof HasOne || $ relation instanceof BelongsTo || $ ...
Handle relation field .
22,279
protected function handleModelField ( $ method , $ label ) { if ( in_array ( $ method , $ this -> model -> getAttributes ( ) ) ) { return $ this -> addField ( $ method , $ label ) ; } return false ; }
Handle model field .
22,280
public function render ( ) { if ( is_callable ( $ this -> builder ) ) { call_user_func ( $ this -> builder , $ this ) ; } if ( $ this -> fields -> isEmpty ( ) ) { $ this -> all ( ) ; } if ( is_array ( $ this -> builder ) ) { $ this -> fields ( $ this -> builder ) ; } $ this -> fields -> each -> setValue ( $ this -> mod...
Render the show panels .
22,281
protected function formatName ( $ column ) { $ columns = explode ( '.' , $ column ) ; if ( count ( $ columns ) == 1 ) { $ name = $ columns [ 0 ] ; } else { $ name = array_shift ( $ columns ) ; foreach ( $ columns as $ column ) { $ name .= "[$column]" ; } } return [ 'start' => "{$name}[start]" , 'end' => "{$name}[end]" ...
Format two field names of this filter .
22,282
public function queryBuilder ( ) { if ( ! $ this -> queryBuilder ) { $ this -> queryBuilder = $ this -> grid -> model ( ) -> getQueryBuilder ( ) ; } return $ this -> queryBuilder ; }
Get model query builder .
22,283
public function column ( $ width , \ Closure $ closure ) { if ( $ this -> columns -> isEmpty ( ) ) { $ column = $ this -> current ; $ column -> setWidth ( $ width ) ; } else { $ column = new Column ( $ width ) ; $ this -> current = $ column ; } $ this -> columns -> push ( $ column ) ; $ closure ( $ this -> parent ) ; }
Add a new column in layout .
22,284
public function columns ( ) { if ( $ this -> columns -> isEmpty ( ) ) { $ this -> columns -> push ( $ this -> current ) ; } return $ this -> columns ; }
Get all columns in filter layout .
22,285
public function removeFilterByID ( $ id ) { $ this -> filters = $ this -> filters -> reject ( function ( AbstractFilter $ filter ) use ( $ id ) { return $ filter -> getId ( ) == $ id ; } ) ; }
Remove filter from column by id .
22,286
public function content ( $ content ) { if ( $ content instanceof Renderable ) { $ this -> content = $ content -> render ( ) ; } else { $ this -> content = ( string ) $ content ; } return $ this ; }
Set box content .
22,287
public function style ( $ styles ) { if ( is_string ( $ styles ) ) { return $ this -> style ( [ $ styles ] ) ; } $ styles = array_map ( function ( $ style ) { return 'box-' . $ style ; } , $ styles ) ; $ this -> class = $ this -> class . ' ' . implode ( ' ' , $ styles ) ; return $ this ; }
Set box style .
22,288
public function pluck ( $ visibleColumn , $ key ) { if ( ! empty ( $ visibleColumn ) && ! empty ( $ key ) ) { $ this -> keyAsValue = true ; } $ this -> visibleColumn = $ visibleColumn ; $ this -> key = $ key ; return $ this ; }
Set visible column and key of data .
22,289
protected function matchRequest ( array $ match , Request $ request ) : bool { if ( ! $ request -> is ( trim ( $ match [ 'path' ] , '/' ) ) ) { return false ; } $ method = collect ( $ match [ 'method' ] ) -> filter ( ) -> map ( function ( $ method ) { return strtoupper ( $ method ) ; } ) ; return $ method -> isEmpty ( ...
If a request match the specific HTTP method and path .
22,290
public static function respond ( Response $ response ) { $ next = function ( ) use ( $ response ) { return $ response ; } ; ( new static ( ) ) -> handle ( Request :: capture ( ) , $ next ) -> send ( ) ; exit ; }
Send a response through this middleware .
22,291
protected function handleErrorResponse ( Response $ response ) { $ exception = $ response -> exception ; $ error = new MessageBag ( [ 'type' => get_class ( $ exception ) , 'message' => $ exception -> getMessage ( ) , 'file' => $ exception -> getFile ( ) , 'line' => $ exception -> getLine ( ) , ] ) ; return back ( ) -> ...
Handle Response with exceptions .
22,292
protected function fetchContents ( $ crawler , $ container ) { $ content = $ crawler -> filter ( $ container ) ; if ( ! $ content -> count ( ) ) { abort ( 422 ) ; } return $ this -> decodeUtf8HtmlEntities ( $ content -> html ( ) ) ; }
Fetch the PJAX - specific HTML from the response .
22,293
public function variables ( ) : array { return [ 'placeholder' => $ this -> placeholder , 'icon' => $ this -> icon , 'type' => $ this -> type , 'group' => $ this -> filter -> group , ] ; }
Get variables for field template .
22,294
protected function prepareRecord ( $ record ) { if ( $ record [ static :: REMOVE_FLAG_NAME ] == 1 ) { return $ record ; } $ prepared = [ ] ; foreach ( $ this -> fields as $ field ) { $ columns = $ field -> column ( ) ; $ value = $ this -> fetchColumnValue ( $ record , $ columns ) ; if ( is_null ( $ value ) ) { continue...
Do prepare work before store and update .
22,295
protected function fetchColumnValue ( $ data , $ columns ) { if ( is_string ( $ columns ) ) { return Arr :: get ( $ data , $ columns ) ; } if ( is_array ( $ columns ) ) { $ value = [ ] ; foreach ( $ columns as $ name => $ column ) { if ( ! Arr :: has ( $ data , $ column ) ) { continue ; } $ value [ $ name ] = Arr :: ge...
Fetch value in input data by column name .
22,296
protected function getEmbeddedData ( ) { if ( $ old = old ( $ this -> column ) ) { return $ old ; } if ( empty ( $ this -> value ) ) { return [ ] ; } if ( is_string ( $ this -> value ) ) { return json_decode ( $ this -> value , true ) ; } return ( array ) $ this -> value ; }
Get data for Embedded form .
22,297
protected function buildEmbeddedForm ( ) { $ form = new EmbeddedForm ( $ this -> column ) ; $ form -> setParent ( $ this -> form ) ; call_user_func ( $ this -> builder , $ form ) ; $ form -> fill ( $ this -> getEmbeddedData ( ) ) ; return $ form ; }
Build a Embedded Form and fill data .
22,298
public function render ( ) { if ( $ this -> html instanceof \ Closure ) { $ this -> html = $ this -> html -> call ( $ this -> form -> model ( ) , $ this -> form ) ; } if ( $ this -> plain ) { return $ this -> html ; } $ viewClass = $ this -> getViewElementClasses ( ) ; return <<<EOT<div class="form-group"> <label ...
Render html field .
22,299
public function disableFilter ( bool $ disable = true ) { $ this -> tools -> disableFilterButton ( $ disable ) ; return $ this -> option ( 'show_filter' , ! $ disable ) ; }
Disable grid filter .