Backpack for Laravel

Backpack for Laravel

A collection of Laravel packages to build a custom admin panel.

Guides    Discussions

Upgrading CRUD 3.2 to 3.3

Requirements

  • PHP 7+
  • Laravel 5.5
  • 15-45 minutes

Breaking changes

  • completely rewritten AjaxTables functionality - we fixed all AjaxTables issues and now AjaxDataTables are the default and only option;
  • in create/update forms, fields without a tab are displayed before all tabs;

As you can see, we've struggled very hard to make this version as backwards-compatible as possible. As such, the upgrade steps are small, and few projects will be negatively affected, unless they've overwritten default functionality.

Upgrade steps

(0) Upgrade dependencies and require the latest versions:

  • upgrade your server to use PHP 7+, if you haven't already;
  • upgrade Laravel to 5.5, if you haven't already;
  • upgrade Backpack\Base and Backpack\CRUD to the latest versions:
composer require backpack/base:"^0.8.0"
composer require backpack/crud:"^3.3.0"

(1) Backpack\CRUD 3.3 comes with Backpack\Base 0.8, which brings in:

If you want to use these Backpack\Base features, please:

  • delete any base blade files that you have not personally customized, from your resources/views/vendor/backpack/base, namely layout.blade.php; or manually make the small modification we've done to them;
  • make the following changes to your resources/views/backpack/base/inc/sidebar.blade.php;
  • republish the CSS and JS assets by running php artisan vendor:publish --provider='Backpack\Base\BaseServiceProvider' --tag=public;
  • if you've customized the Base routes by adding a routes/backpack/base.php file to your project, please make sure you also include the new routes, for changing the password and the user info;

(2) If you use tabs in your CRUD's create/update forms, please make sure all your fields have the "tab" attribute specified. Fields that do not have a tab specified were put in the last tab in 3.2, but they will now be put before all tabs.

(3) If you're using AjaxDataTables and you've customized the search() method in one of your CrudControllers to fix one of the "unfixable" issues in the prior implementation, you can now delete that method. It should "just work".

(4) If you're NOT using AjaxDataTables, you will, after you upgrade. All CRUD tables are now AjaxDataTables.

(5) If you've used model_function, model_function_attribute columns or the text column to actually get an accessor, in any of your CRUDs, they will now work, even in your shiny new Ajax tables. But the search functionality will ignore them. This is a natural limitation - a model function pulls something from the database and manipulates it, no DBMS can search within something that's not inside the DBMS. But we have introduced a nifty system so that you can allow your users to search those columns: you can now customize how a column is being searched, using the searchLogic attribute. Set it to false and the column won't be searchable. Set it to a closure and that closure will be run upon search. Here are some relevant examples:

<?php

$this->crud->addColumn([
    'name' => 'full_name', // there is no full_name column in the db, it's an accessor 
    'type' => 'text',
    'label' => 'Full Name',
    'searchLogic' => function ($query, $column, $searchTerm) {
        $query->orWhere('first_name', 'like', '%'.$searchTerm.'%');
        $query->orWhere('last_name', 'like', '%'.$searchTerm.'%');
    }
]);

$this->crud->addColumn([
    'name' => 'getColoredStatus', 
    'type' => 'model_function',
    'label' => 'Status',
    'searchLogic' => function ($query, $column, $searchTerm) {
        $query->orWhere('status', 'like', '%'.$searchTerm.'%');
    }
]);

(6) Please note, for select and select_multiple columns, AjaxDataTable now searches within the connected entities.

(7) If you're using the Backpack\PageManager package, you might need to run a composer update to update that to the latest version too. Your installed package might not have the search route for Pages, but the latest version does.

Upgrading CRUD 3.2 to 3.3


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.