Use BLACKFRIDAY2023 coupon to get 40% discount on anything.

Only 1 purchases left with this discount. Promo expires 2 days from now.




CRUD API Cheat Sheet

Here are all the functions you will be using inside your EntityCrudController's setup() method, grouped by the operation you will most likely use them for.




Methods: addColumn(), addColumns(), modifyColumn(), removeColumn(), removeColumns(), setColumnDetails(), setColumnsDetails(), setColumns(), beforeColumn(), afterColumn(), makeFirstColumn()

// Manipulate what columns are shown in the table view.
$this->crud->addColumn($column_definition_array); // add a column, at the end of the stack
$this->crud->addColumns([$column_definition_array, $another_column_definition_array]); // add multiple columns, at the end of the stack
$this->crud->modifyColumn($name, $modifs_array);
$this->crud->removeColumn('column_name'); // remove a column from the stack
$this->crud->removeColumns(['column_name_1', 'column_name_2']); // remove an array of columns from the stack
$this->crud->setColumnDetails('column_name', ['attribute' => 'value']);
$this->crud->setColumnsDetails(['column_1', 'column_2'], ['attribute' => 'value']);

$this->crud->setColumns(); // set the columns you want in the table view, either as array of column names, or multidimensional array with all columns detailed with their types

$this->crud->addColumn()->beforeColumn('name'); // will show this before the given column
$this->crud->addColumn()->afterColumn('name'); // will show this after the given column

  // will make this column the first one in the list
  // you need to also specify priority 1 in your addColumn statement for details_row or responsive expand buttons to show


Methods: buttons(), addButton(), addButtonFromModelFunction(), addButtonFromView(), removeButton(), removeButtonFromStack(), removeButtons(), removeAllButtons(), removeAllButtonsFromStack(), modifyButton(), moveButton()

// possible stacks: 'top', 'line', 'bottom';
// possible positions: 'beginning' and 'end'; defaults to 'beginning' for the 'line' stack, 'end' for the others;
$this->crud->buttons(); // collection of all buttons
$this->crud->addButton($stack, $name, $type, $content, $position); // possible types are: 'view', 'model_function'
$this->crud->addButtonFromModelFunction($stack, $name, $model_function_name, $position); // add a button whose HTML is returned by a method in the CRUD model
$this->crud->addButtonFromView($stack, $name, $view, $position); // add a button whose HTML is in a view placed at resources\views\vendor\backpack\crud\buttons
$this->crud->removeButtonFromStack($name, $stack);
$this->crud->removeButtons($names, $stack);
$this->crud->orderButtons($stack, $order); // order is an array with button names in the new order
$this->crud->modifyButton($name, $modifications); // modifications are the attributes and their new values
$this->crud->moveButton($target, $where, $destination); // move the target button to the destination position, target and destion are the button names, where is 'before' or 'after'


Methods: addFilter(), modifyFilter(), removeFilter(), removeAllFilters(), filters()

// Manipulate what filters are shown in the table view.
// Note: check out CRUD > Features > Filters in the docs to see examples of $filter_definition_array
$this->crud->addFilter($filter_definition_array, $values, $filter_logic);
$this->crud->modifyFilter($name, $modifs_array);
$this->crud->filters(); // gets all the filters

Details Row

Methods: enableDetailsRow(), disableDetailsRow()

// Shows a + sign next to each table row, so that the user can expand that row and reveal details. You are responsible for creating the view with those details.
// NOTE: you also need to do allow access to the right users: $this->crud->allowAccess('details_row');
// NOTE: you also need to do overwrite the showDetailsRow($id) method in your EntityCrudController to show whatever you'd like in the details row OR overwrite the views/backpack/crud/details_row.blade.php


Export Buttons

Methods: enableExportButtons()

// Show export to PDF, CSV, XLS and Print buttons on the table view. Please note it will only export the current _page_ of results. So in order to export all entries the user needs to make the current page show "All" entries from the top-left picker.

Responsive Table

Methods: enableResponsiveTable(), disableResponsiveTable()


Persistent Table

Methods: enablePersistentTable(), disablePersistentTable()


Page Length

Methods: setDefaultPageLength(), setPageLengthMenu()

// you can define the default page length. If it does not exist we will add it to the pagination array.

// you can configure the paginator shown to the user in various ways

// values and labels, 1st array the values, 2nd array the labels:
$this->crud->setPageLengthMenu([[100, 200, 300], ['one hundred', 'two hundred', 'three hundred']]); 

// values and labels in one array:
$this->crud->setPageLengthMenu([100 => 'one hundred', 200 => 'two hundred', 300 => 'three hundred']); 

// only values, we will use the values as labels:
$this->crud->setPageLengthMenu([100, 200, 300]); // OR
$this->crud->setPageLengthMenu([[100, 200, 300]]); 

// only one option available:

NOTE: Do not use 0 as a key, if you want to represent "ALL" use -1 instead.

Actions Column

Methods: setActionsColumnPriority()

// make the actions column (in the table view) hide when not enough space is available, by giving it an unreasonable priority

Custom / Advanced Queries

Methods: addClause(), groupBy(), limit(), orderBy()

// Change what entries are shown in the table view.
// This changes all queries on the table view,
// as opposed to filters, who only change it when that filter is applied. 
$this->crud->addClause('active'); // apply local scope
$this->crud->addClause('type', 'car'); // apply local dynamic scope
$this->crud->addClause('where', 'name', '=', 'car');
$this->crud->addClause('whereName', 'car');
$this->crud->addClause('whereHas', 'posts', function($query) {

// please note it's generally a good idea to use crud->orderBy() inside "if (!$this->crud->getRequest()->has('order')) {}"; that way, your custom order is applied ONLY IF the user hasn't forced another order (by clicking a column heading)


Use the same Columns API as for the ListEntries operation, but inside your show() method.

Create & Update Operations

Methods: addField(), addFields(), modifyField(), modifyFields(), removeField(), removeFields(), removeAllFields(), beforeField(), afterField()

// ------
// ------
// Manipulate what fields are shown in the create / update forms.
// Note: check out CRUD > Features > Field Types in the docs to see examples of $field_definition_array

$this->crud->addField('db_column_name'); // a lazy way to add fields: let the CRUD decide what field type it is and set it automatically, along with the field label
$this->crud->modifyField($name, $modifs_array);

$this->crud->addField()->beforeField('name'); // will show this before the given field
$this->crud->addField()->afterField('name'); // will show this after the given field


Methods: enableReorder(), disableReorder(), isReorderEnabled()

    protected function setupReorderOperation()
        // model attribute to be shown on draggable items
        $this->crud->set('reorder.label', 'name'); 
        // maximum number of nesting allowed
        $this->crud->set('reorder.max_level', 2);

        // extras:
        // $this->crud->disableReorder();
        // $this->crud->isReorderEnabled();


// -------------------------
// REVISIONS aka Audit Trail
// -------------------------
// Tracks all changes to an entry and provides an interface to revert to a previous state.
// IMPORTANT: You also need to use \Venturecraft\Revisionable\RevisionableTrait;
// Please check out: https://backpackforlaravel.com/docs/crud-operation-revisions

All Operations

Methods: allowAccess(), denyAccess(), hasAccess(), hasAccessOrFail(), hasAccessToAll(), hasAccessToAny(), setShowView(), setEditView(), setCreateView(), setListView(), setReorderView(), setRevisionsView, setRevisionsTimelineView(), setDetailsRowView(), getEntry(), getFields(), getColumns(), getCurrentEntry(), getTitle(), setTitle(), getHeading(), setHeading(), getSubheading(), setSubheading(),

// ------ 
// ------
// Prevent or allow users from accessing different CRUD operations.

$this->crud->allowAccess(['list', 'create', 'delete']);
$this->crud->denyAccess(['list', 'create', 'delete']);

$this->crud->hasAccess('add'); // returns true/false
$this->crud->hasAccessOrFail('add'); // throws 403 error
$this->crud->hasAccessToAll(['create', 'update']); // returns true/false
$this->crud->hasAccessToAny(['create', 'update']); // returns true/false

// -------------
// -------------

// eager load a relationship

// ------------
// ------------

// use a custom view for a CRUD operation

// -------------
// -------------

// use a custom CSS class for the content of a CRUD operation

// -------
// -------



// in your update() method, after calling parent::updateCrud()

// -------
// -------


// -------
// -------

$this->crud->getActionMethod(); // returns the method on the controller that was called by the route; ex: create(), update(), edit() etc;
$this->crud->actionIs('create'); // checks if the controller method given is the one called by the route

$this->crud->getTitle('create'); // get the Title for the create action
$this->crud->getHeading('create'); // get the Heading for the create action
$this->crud->getSubheading('create'); // get the Subheading for the create action

$this->crud->setTitle('some string', 'create'); // set the Title for the create action
$this->crud->setHeading('some string', 'create'); // set the Heading for the create action
$this->crud->setSubheading('some string', 'create'); // set the Subheading for the create action

// ---------------------------
// CrudPanel Basic Information
// ---------------------------
// OR $this->crud->setRouteName("admin.example");
$this->crud->setEntityNameStrings("example", "examples");

// check the FormRequests used in that EntityCrudController for required fields, and add an asterisk to them in the create/edit form
$this->crud->setRequiredFields(StoreRequest::class, 'create');
$this->crud->setRequiredFields(UpdateRequest::class, 'edit');

Like our open-core?

Then you'll love our premium add-ons - productivity tools and tons of new features.