From 0ac303397d7007a04e8bf16da0799db7d07bb368 Mon Sep 17 00:00:00 2001 From: Jesper Noordsij <45041769+jnoordsij@users.noreply.github.com> Date: Thu, 6 Mar 2025 14:27:23 +0100 Subject: [PATCH 01/32] Add basset:clear to upgrade guide --- 7.x-dev/upgrade-guide.md | 1 + 1 file changed, 1 insertion(+) diff --git a/7.x-dev/upgrade-guide.md b/7.x-dev/upgrade-guide.md index ed34d99..23c411a 100644 --- a/7.x-dev/upgrade-guide.md +++ b/7.x-dev/upgrade-guide.md @@ -121,6 +121,7 @@ No changes needed. Step xx. Clear your app's cache: ``` +php artisan basset:clear php artisan config:clear php artisan cache:clear php artisan view:clear From bf9375ab584a4652a05aaa7cd734f38a629ab4c9 Mon Sep 17 00:00:00 2001 From: pxpm Date: Fri, 30 May 2025 15:53:29 +0100 Subject: [PATCH 02/32] wip --- 7.x-dev/base-widgets.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/7.x-dev/base-widgets.md b/7.x-dev/base-widgets.md index d984ee6..bd80160 100644 --- a/7.x-dev/base-widgets.md +++ b/7.x-dev/base-widgets.md @@ -349,6 +349,27 @@ class ChartjsPieController extends ChartController
+ +### Datatable + +Allow you to show a datatable for your CrudControllers. + +```php +[ + 'type' => 'datatable', + 'controller' => 'App\Http\Controllers\Admin\PetShop\InvoiceCrudController', + 'name' => 'invoice_crud', + 'configure' => function($crud, $parent) { + // you can use this closure to modify your CrudController definition. + if ($parent) { + $crud->addClause('where', 'owner_id', $parent->id); + } + } +] +``` + + +
### Div From c572e8f184e041348f67be9ddff5d62dbee8525b Mon Sep 17 00:00:00 2001 From: pxpm Date: Fri, 30 May 2025 16:11:00 +0100 Subject: [PATCH 03/32] docs for component --- 7.x-dev/base-components.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/7.x-dev/base-components.md b/7.x-dev/base-components.md index 8f61b76..ea6ed11 100644 --- a/7.x-dev/base-components.md +++ b/7.x-dev/base-components.md @@ -46,6 +46,19 @@ Note that you can further customize this using custom attributes. If you define
+ +### Datatable + +Show a datatable for the defined controller. + +```php + +``` + +Note that you can further customize this using custom attributes. If you define a `target` on it, that will be passed down to the `a` element. + +
+ ### Menu Separator From 0bbd8967a913774d8edbcc77e430e368230ad343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20T=C4=83b=C4=83citu?= Date: Mon, 2 Jun 2025 11:22:27 +0300 Subject: [PATCH 04/32] detail the datatable components a bit --- 7.x-dev/base-components.md | 11 ++++++++--- 7.x-dev/base-widgets.md | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/7.x-dev/base-components.md b/7.x-dev/base-components.md index ea6ed11..07fb27d 100644 --- a/7.x-dev/base-components.md +++ b/7.x-dev/base-components.md @@ -47,12 +47,17 @@ Note that you can further customize this using custom attributes. If you define
-### Datatable +### DataTable -Show a datatable for the defined controller. +Show a datatable _anywhere you want_, so the admin to easily list, filter, search and perform other operations on entries of an Eloquent model. The datatable component is a extension of a CrudController - so a CRUD for that entity needs to be already set up, and passed to this component as a parameter. The datatable will pick up everything that in your `setupListOperation()`. You can then further add/remove/configure functionality using the configuration closure: ```php - + ``` Note that you can further customize this using custom attributes. If you define a `target` on it, that will be passed down to the `a` element. diff --git a/7.x-dev/base-widgets.md b/7.x-dev/base-widgets.md index bd80160..70d8952 100644 --- a/7.x-dev/base-widgets.md +++ b/7.x-dev/base-widgets.md @@ -350,9 +350,9 @@ class ChartjsPieController extends ChartController
-### Datatable +### DataTable -Allow you to show a datatable for your CrudControllers. +Shows a datatable component from a particular CrudController. For more info about the configuration parameter, please see the [datatable component docs](/docs/{{version}}/base-components#datatable). ```php [ From d0e1d1a2f72c166a602ce78dd34dd2b760fad9bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20T=C4=83b=C4=83citu?= Date: Mon, 2 Jun 2025 12:00:21 +0300 Subject: [PATCH 05/32] polish datatable component docs --- 7.x-dev/base-components.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/7.x-dev/base-components.md b/7.x-dev/base-components.md index 07fb27d..c7d2107 100644 --- a/7.x-dev/base-components.md +++ b/7.x-dev/base-components.md @@ -49,7 +49,7 @@ Note that you can further customize this using custom attributes. If you define ### DataTable -Show a datatable _anywhere you want_, so the admin to easily list, filter, search and perform other operations on entries of an Eloquent model. The datatable component is a extension of a CrudController - so a CRUD for that entity needs to be already set up, and passed to this component as a parameter. The datatable will pick up everything that in your `setupListOperation()`. You can then further add/remove/configure functionality using the configuration closure: +Show a datatable _anywhere you want_, so the admin to easily list, filter, search and perform other operations on entries of an Eloquent model. The datatable component is a extension of a CrudController - so a CRUD for that entity needs to be already set up, and passed to this component as a parameter: ```php ``` -Note that you can further customize this using custom attributes. If you define a `target` on it, that will be passed down to the `a` element. +The datatable will pick up everything that in your `setupListOperation()`. You can then further add/remove/configure functionality using the configuration closure: + +```php + + +```
From 52bee18549689b3fa75e218204c2f164963e95b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20T=C4=83b=C4=83citu?= Date: Thu, 5 Jun 2025 13:17:28 +0300 Subject: [PATCH 06/32] use bp-datatable syntax --- 7.x-dev/base-components.md | 20 +++++++------------- 7.x-dev/base-widgets.md | 4 ++-- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/7.x-dev/base-components.md b/7.x-dev/base-components.md index c7d2107..bfcb805 100644 --- a/7.x-dev/base-components.md +++ b/7.x-dev/base-components.md @@ -51,24 +51,18 @@ Note that you can further customize this using custom attributes. If you define Show a datatable _anywhere you want_, so the admin to easily list, filter, search and perform other operations on entries of an Eloquent model. The datatable component is a extension of a CrudController - so a CRUD for that entity needs to be already set up, and passed to this component as a parameter: -```php - +```html + ``` The datatable will pick up everything that in your `setupListOperation()`. You can then further add/remove/configure functionality using the configuration closure: -```php - - + :setup="function($crud, $parent) { if ($parent) { $crud->addClause('where', 'customer_id', $parent->id); } }" + name="invoices" /> ``` diff --git a/7.x-dev/base-widgets.md b/7.x-dev/base-widgets.md index 70d8952..a1d1a5b 100644 --- a/7.x-dev/base-widgets.md +++ b/7.x-dev/base-widgets.md @@ -358,8 +358,8 @@ Shows a datatable component from a particular CrudController. For more info abou [ 'type' => 'datatable', 'controller' => 'App\Http\Controllers\Admin\PetShop\InvoiceCrudController', - 'name' => 'invoice_crud', - 'configure' => function($crud, $parent) { + 'name' => 'invoices', + 'setup' => function($crud, $parent) { // you can use this closure to modify your CrudController definition. if ($parent) { $crud->addClause('where', 'owner_id', $parent->id); From 7b217a394a47ea9a3f2851aa2e11c7d77620766f Mon Sep 17 00:00:00 2001 From: pxpm Date: Fri, 6 Jun 2025 15:00:47 +0100 Subject: [PATCH 07/32] wip --- 7.x-dev/base-components.md | 4 ++-- 7.x-dev/upgrade-guide.md | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/7.x-dev/base-components.md b/7.x-dev/base-components.md index bfcb805..6f198f7 100644 --- a/7.x-dev/base-components.md +++ b/7.x-dev/base-components.md @@ -52,13 +52,13 @@ Note that you can further customize this using custom attributes. If you define Show a datatable _anywhere you want_, so the admin to easily list, filter, search and perform other operations on entries of an Eloquent model. The datatable component is a extension of a CrudController - so a CRUD for that entity needs to be already set up, and passed to this component as a parameter: ```html - + ``` The datatable will pick up everything that in your `setupListOperation()`. You can then further add/remove/configure functionality using the configuration closure: ```html - :setup="function($crud, $parent) { if ($parent) { $crud->addClause('where', 'customer_id', $parent->id); } }" diff --git a/7.x-dev/upgrade-guide.md b/7.x-dev/upgrade-guide.md index ed34d99..b48b3ed 100644 --- a/7.x-dev/upgrade-guide.md +++ b/7.x-dev/upgrade-guide.md @@ -109,7 +109,10 @@ No changes needed. ### Views -No changes needed. +**List Operation View** - The List Operation view got a huge change. We decoupled the datatable from the view, so that you can use the table anywhere you would like. +Most of the code is still identical but moved to `datatable.blade.php`. The `list.blade.php` view now only includes the mentioned datatable component. + +If you had customized the `list.blade.php` you should move your customizations to `datatable.blade.php`. ### Security From 87578f802c4c81e2c0e8c94ac49641ce45c0b6c8 Mon Sep 17 00:00:00 2001 From: Cristian Tabacitu Date: Thu, 19 Jun 2025 15:04:08 +0300 Subject: [PATCH 08/32] add docs for datagrid and datalist components --- 7.x-dev/base-components.md | 207 ++++++++++++++++++++++++++++++++----- 1 file changed, 180 insertions(+), 27 deletions(-) diff --git a/7.x-dev/base-components.md b/7.x-dev/base-components.md index 6f198f7..f18255b 100644 --- a/7.x-dev/base-components.md +++ b/7.x-dev/base-components.md @@ -30,8 +30,8 @@ All components also allow you to specify custom attributes. When you specify a c Even though the 'target' attribute doesn't _technically_ exist in the component, that attribute will be placed on that component's `a` element. - -## Available Components + +## UI Components ### Menu Item @@ -46,29 +46,6 @@ Note that you can further customize this using custom attributes. If you define
- -### DataTable - -Show a datatable _anywhere you want_, so the admin to easily list, filter, search and perform other operations on entries of an Eloquent model. The datatable component is a extension of a CrudController - so a CRUD for that entity needs to be already set up, and passed to this component as a parameter: - -```html - -``` - -The datatable will pick up everything that in your `setupListOperation()`. You can then further add/remove/configure functionality using the configuration closure: - -```html - - :setup="function($crud, $parent) { if ($parent) { $crud->addClause('where', 'customer_id', $parent->id); } }" - name="invoices" - /> -``` - -
- - ### Menu Separator @@ -96,12 +73,188 @@ To show a dropdown menu, with elements, you can use the `menu-dropdown` and `men ``` -Notes: -- on `menu-dropdown` you can define `nested="true"` to flag that dropdown as nested (aka. having a parent); so you can have dropdown in dropdown in dropdown; +Notes: +- on `menu-dropdown` you can define `nested="true"` to flag that dropdown as nested (aka. having a parent); so you can have dropdown in dropdown in dropdown; - on both components, you can also define custom attributes; eg. if you define a `target` on one, that will be passed down to the `a` element;
+ +## Data Components + +These are the components that Backpack uses inside the default CRUD operations. Starting Backpack v7, they are exposed as components, so that you can also use them _outside_ the CrudControllers, or in your custom operations. + + +### Datatable + +![Backpack v7 Datatable component](https://backpackforlaravel.com/uploads/v7/datatable_component.jpg) + +Useful if you want to show the entries in the database, for an Eloquent model. This component shows a datatable _anywhere you want_, so the admin to easily list, filter, search and perform other operations on entries of an Eloquent model. The datatable component is a extension of a CrudController - so a CrudController for that entity needs to be already set up, and passed to this component as a parameter: + +```html + +``` + +**Configuration options:** +- `name='invoices_datatable'` - by default, a name will be generated; but you can pick one you can recognize; +- `operation='list'` - by default, the datatable component will pick up everything that controller sets up for the List operation; if you want to change the operation it will initialize, you can pass this parameter; +- `:setup="function($crud, $parent) {}"` - if you want to make changes to the operation setup (eg. add/remove columns, configure functionality), you can use this parameter; the closure passed here will be run _after_ the setup of that operation had already completed; + +**Advanced example:** + +```html + +``` + +
+ + +### Datagrid + +![Backpack v7 Datagrid component](https://backpackforlaravel.com/uploads/v7/datagrid_component.jpg) + +Useful if you want to show the attributes of an entry in the database (the attributes of an Eloquent model). This components shows a grid view with all attributes that are configured using CRUD columns. + +There are two ways to use the Datagrid component: + +#### Datagrid for an existing CrudController + +Your datagrid will pick up the configuration in your CrudController automatically. + + +```html + +``` + +**Configuration options:** +- `name='datagrid'` - by default, a name will be generated; but you can pick one you can recognize; +- `operation='show'` - by default, the datagrid component will pick up everything that controller sets up for the Show operation; if you want to change the operation it will initialize, you can pass this parameter; +- `:setup="function($crud, $entry) {}"` - if you want to make changes to the operation setup (eg. add/remove columns, configure functionality), you can use this parameter; the closure passed here will be run _after_ the setup of that operation had already completed; + +**Advanced example:** + +```html + +``` + +#### Datagrid for an Eloquent entry + +If you want to show a datagrid component for a entity that does _not_ have a CrudController, you can do that too. But you have to manually specify the columns you want to be shown: + +```html + +``` + + +
+ + +### Datalist + +![Backpack v7 Datalist component](https://backpackforlaravel.com/uploads/v7/datalist_component.jpg) + +Useful if you want to show the attributes of an entry in the database (the attributes of an Eloquent model). This components shows a table with all attributes that are configured using CRUD columns. + +There are two ways to use the Datalist component: + +#### Datalist for an existing CrudController + +Your datalist will pick up the configuration in your CrudController automatically. + + +```html + +``` + +**Configuration options:** +- `name='invoices_datalist'` - by default, a name will be generated; but you can pick one you can recognize; +- `operation='show'` - by default, the datalist component will pick up everything that controller sets up for the Show operation; if you want to change the operation it will initialize, you can pass this parameter; +- `:setup="function($crud, $entry) {}"` - if you want to make changes to the operation setup (eg. add/remove columns, configure functionality), you can use this parameter; the closure passed here will be run _after_ the setup of that operation had already completed; + +**Advanced example:** + +```html + +``` + +#### Datalist for an Eloquent entry + +If you want to show a datalist component for a entity that does _not_ have a CrudController, you can do that too. But you have to manually specify the columns you want to be shown: + +```html + +``` + + +
+ + +## Syntaxes for Using Components + +All components that Backpack provides are available to use both using the "full namespace" syntax: + +```html + +``` + +and using the slightly shorter "alias" syntax: + +```html + +``` + +You can use whichever one you prefer. But please note that if you need to pass the components to a dynamic Laravel Blade component, only the "alias" syntax will work (eg. you will pass `:component='bp-datagrid'`). This is a limitation from Laravel, not Backpack. + + ## Overriding Default Components From c0ed9c04d9680ee252047dd49e9262744116a72a Mon Sep 17 00:00:00 2001 From: Cristian Tabacitu Date: Sat, 21 Jun 2025 13:12:15 +0300 Subject: [PATCH 09/32] add docs for chip widget --- 7.x-dev/base-widgets.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/7.x-dev/base-widgets.md b/7.x-dev/base-widgets.md index a1d1a5b..0f09c6c 100644 --- a/7.x-dev/base-widgets.md +++ b/7.x-dev/base-widgets.md @@ -347,6 +347,23 @@ class ChartjsPieController extends ChartController ``` +
+ + +### Chip + +Shows a chip blade view - which is useful to show more information about a database entry, using little screen real estate. + +```php +[ + 'type' => 'chip', + 'view' => 'crud::chips.general', + 'title' => 'invoices', + 'entry' => Invoice::first(), +] +``` + +
@@ -360,7 +377,7 @@ Shows a datatable component from a particular CrudController. For more info abou 'controller' => 'App\Http\Controllers\Admin\PetShop\InvoiceCrudController', 'name' => 'invoices', 'setup' => function($crud, $parent) { - // you can use this closure to modify your CrudController definition. + // you can use this closure to modify your CrudController definition. if ($parent) { $crud->addClause('where', 'owner_id', $parent->id); } @@ -388,7 +405,7 @@ Allows you to include multiple widgets within a "div" element with the attribute ] ``` -Anything you specify on this widget, other than ```type``` and ```content```, has to be a string, and will be considered an attribute of the "div" element. +Anything you specify on this widget, other than ```type``` and ```content```, has to be a string, and will be considered an attribute of the "div" element. For example, in the following snippet, ```class``` and ```custom-attribute``` are attributes of the "div" element: ```php From 2042b56dc6715eec76e25bd034418b639cf882d3 Mon Sep 17 00:00:00 2001 From: Cristian Tabacitu Date: Sat, 21 Jun 2025 13:56:46 +0300 Subject: [PATCH 10/32] add new page for chips --- 7.x-dev/crud-chips.md | 222 ++++++++++++++++++++++++++++++++++++++++++ 7.x-dev/index.md | 4 +- 2 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 7.x-dev/crud-chips.md diff --git a/7.x-dev/crud-chips.md b/7.x-dev/crud-chips.md new file mode 100644 index 0000000..6f74c17 --- /dev/null +++ b/7.x-dev/crud-chips.md @@ -0,0 +1,222 @@ +# Chips + +--- + + +## About + +A chips helps show the information of a database entry, in a format that takes up little space visually. + +It can be used inside operations to: +- show more info inside a table cell in **ListOperation**; +- show a related item in more detail in **ShowOperation**; + +A chip consists of only one file - a blade file with the same name as the chip type (ex: ```general.blade.php```). Backpack provides you with one chip type, that is designed to accomodate many types of database entries, but you can easily [create an entirely new chip type](#creating-a-custom-chip-type). + + +### Default Chip Types + + +#### General Chip + +// TODO: add image of general chip + +This chip was designed to be so general, that it's useful to show _most_ types of information from the database. + +```php +@include('crud::chips.general', [ + 'text' => 'John Doe', + 'title' => 'Example of a chip without URL', + 'url' => 'https://google.com/', + 'target' => '_blank', + 'image' => asset('uploads/person1.jpg'), + 'details' => [ + [ + 'icon' => 'la la-hashtag', + 'text' => '8AH13A7', + 'url' => 'mailto:john.doe@example.com', + 'title' => 'Click to email', + ], + [ + 'icon' => 'la la-envelope', + 'text' => 'john.doe@example.com', + 'url' => 'mailto:john.doe@example.com', + 'title' => 'Click to email', + ], + [ + 'icon' => 'la la-phone', + 'text' => '+1 (555) 123-4567', + 'url' => 'tel:+15551234567', + 'title' => 'Click to call', + ] + ] +]) +``` + + +### How to use chips + +Depending on _where_ you want to use a chip, there are a few ways you can do that. Remember - a chip is a simple blade file, so the methods below should be pretty intuitive: + + +#### How to use a chip inside a custom blade view + +// TODO: image with chip inside a custom blade view + +If you want to load a chip inside a custom page, custom component or anything else custom, you can just include the blade view directly, and pass whatever attributes you want to show. For example, if you want to use the `general` chip you can just include that blade file, and pass some of the variables it supports: + +```php +{{-- Example of General chip for a person, with data from Eloquent model --}} +@include('crud::chips.general', [ + 'text' => $user->name, + 'url' => backpack_url('http://github.com/user/'.$user-%3Eid.'/show'), + 'showImage' => false, + // 'image' => backpack_avatar_url(http://github.com/$user), // doesn't work well with dummy data + 'details' => [ + [ + 'icon' => 'la la-hashtag', + 'text' => $user->id, + 'url' => backpack_url('http://github.com/user/'.$user-%3Eid.'/show'), + 'title' => 'Click to preview', + ], + [ + 'icon' => 'la la-envelope', + 'text' => $user->email, + 'url' => 'mailto:'.$user->email, + 'title' => 'Click to email', + ], + [ + 'icon' => 'la la-calendar', + 'text' => $user->created_at->format('F j, Y'), + 'title' => 'Created at '.$user->created_at, + ] + ] +]) +``` + + +#### How to use a chip as a datatable column + +// TODO: image of CRUD before and after using chips in a Datatable + +When your datatables have too many columns, chips become very useful. They allow you to group multiple columns inside a chip, reducing the number of columns and thereby showing more information in less space. No longer will your admins have to expand the table row or use horizontal scrolling to see important info. + +Remember, a chip is just a simple blade file. So to use a chip as a column, we can just use the `view` column type, and pass the path to our chip file. For example: + +```php +// after we create an `invoice` chip +// we can use that chip as a column: +CRUD::addColumn([ + 'name' => 'info', + 'type' => 'view', + 'view' => 'crud::chips.invoice', +]); +``` +By default, the view column type is not searchable. In order to make your chip columns searchable you need to [specify a custom ```searchLogic``` in your declaration](/docs/{{version}}/crud-columns#custom-search-logic). + + +#### How to use a chip as a widget + +// TODO: image with chip as a widget + +Chip files usually only contain the minimum content and styling necessary. You can include them as widgets directly, but they probably won't look very pretty on a custom page, because they don't have a background, borders, shadow etc. That's why we've also created a `chip` widget, which adds wrappers just like the other widgets - so that your chip will look good when placed on a custom page (or an existing CRUD page, why not). + +To use the `chip` widget, you can do: + +```php +Widget::add() + ->to('after_content') // optional + ->type('chip') + ->view('crud::chips.owner') + ->title('Owner') + ->entry($owner); +``` + +
+ + +## Overwriting Default Chip Types + +You can overwrite a chip type by placing a file with the same name in your ```resources\views\vendor\backpack\crud\chips``` directory. But it is NOT recommended to do so. When you're overwriting a default chip type, you're forfeiting any future updates for that chip. We can't push updates to a file that you're no longer using. + +In 99.9% of the cases, it's recommended NOT to override the default `general` chip file, but to create a _custom_ chip file. That will make it a lot easier to upgrade to newer versions of Backpack - because the file is completely in your control. + +
+ + +## Creating a Custom Chip Type + +Chips consist of only one file - a blade file with the same name as the chip type (ex: ```person.blade.php```). You can create one by placing a new blade file inside ```resources\views\vendor\backpack\crud\chips```. Be careful to choose a distinctive name - usually the model name works best. + +// TODO: create this command +To create a new chip file in the standard directory, you can run `php artisan backpack:chip {chip-file-name}`. This will create a new file in that directory, from a stub, for you to customize however you want. + +For example, you can do `php artisan backpack:chip person` to create a ```person.blade.php``` then includes the HTML content directly: + +```html +
+
+
+
+
+ +
+
+
+ +
+ + + 8AH13A7 + + + + john.doe@example.com + + + + +1 (555) 123-4567 + +
+
+
+
+``` + +But most likely, you'll want to create a chip that outputs some information for a particular database entry. If you like how the `general` chip looks, and only want to make it easy to re-use the chip, you can create a chip that includes the `general` chip. For example: + +```php +@php + $last_purchase = $entry->invoices()->orderBy('issuance_date', 'DESC')->first()->issuance_date; +@endphp + +@include('crud::chips.general', [ + 'text' => $entry->name, + 'url' => backpack_url('http://github.com/pet-shop/owner/'.$entry-%3Eid.'/show'), + 'image' => asset($entry->avatar->url), + // 'showImage' => false, + 'details' => [ + [ + 'icon' => 'la la-dog', + 'text' => $entry->pets->count().' pets', + 'title' => 'Number of pets: '.$entry->pets->count(), + ], + [ + 'icon' => 'la la-shopping-cart', + 'text' => $entry->invoices->count(). ' purchases', + 'title' => 'Number of purchases: '.$entry->invoices->count(), + ], + [ + 'icon' => 'la la-calendar', + 'text' => $last_purchase->format('F j, Y'), + 'title' => 'Last purchase: '.$last_purchase, + ] + ] +]) +``` + +Otherwise, you can create a completely custom chip, that looks and works differently from the `general` chip. There are no limitations - since chips are simple blade files. diff --git a/7.x-dev/index.md b/7.x-dev/index.md index cb6360d..c46ebe0 100644 --- a/7.x-dev/index.md +++ b/7.x-dev/index.md @@ -16,7 +16,7 @@ - [3. Advanced Features](/docs/{{version}}/getting-started-advanced-features) - [4. Add-ons, License & Support](/docs/{{version}}/getting-started-license-and-support) - [Tutorials](/docs/{{version}}/tutorials) - + #### Admin UI - [About](/docs/{{version}}/base-about) @@ -36,6 +36,7 @@ + [Columns](/docs/{{version}}/crud-columns) + [Buttons](/docs/{{version}}/crud-buttons) + [Filters](/docs/{{version}}/crud-filters) + + [Chips](/docs/{{version}}/crud-chips) + [Create](/docs/{{version}}/crud-operation-create) & [Update](/docs/{{version}}/crud-operation-update) + [Fields](/docs/{{version}}/crud-fields) + [Save Actions](/docs/{{version}}/crud-save-actions) @@ -44,6 +45,7 @@ + [Delete](/docs/{{version}}/crud-operation-delete) + [Show](/docs/{{version}}/crud-operation-show) + [Columns](/docs/{{version}}/crud-columns) + + [Chips](/docs/{{version}}/crud-chips) - [Additional Operations](/docs/{{version}}/crud-operations) + [Clone](/docs/{{version}}/crud-operation-clone) + [Reorder](/docs/{{version}}/crud-operation-reorder) From 1451ca6131ba7215914a894e2246acc9d4348a25 Mon Sep 17 00:00:00 2001 From: Cristian Tabacitu Date: Tue, 24 Jun 2025 12:48:45 +0300 Subject: [PATCH 11/32] add docs for dataform component --- 7.x-dev/base-components.md | 42 ++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/7.x-dev/base-components.md b/7.x-dev/base-components.md index f18255b..139b2d7 100644 --- a/7.x-dev/base-components.md +++ b/7.x-dev/base-components.md @@ -84,6 +84,40 @@ Notes: These are the components that Backpack uses inside the default CRUD operations. Starting Backpack v7, they are exposed as components, so that you can also use them _outside_ the CrudControllers, or in your custom operations. + + +### Dataform + +![Backpack v7 Dataform component](https://backpackforlaravel.com/uploads/v7/dataform_component.jpg) + +This component helps you show a form _anywhere you want_, so the admin to easily create or edit an entries for an Eloquent model. The dataform component is a extension of a CrudController - so a CrudController for that entity needs to be already set up, and passed to this component as a parameter: + +```html + +``` + +**Configuration options:** +- `name='invoice_form'` - by default, a name will be generated; but you can pick one you can recognize; +- `operation='create'` - by default, the datatable component will pick up everything that controller sets up for the Create operation; if you want to change the operation it will initialize, you can pass this parameter; +- `:entry="\App\Models\Invoice::find(1)"` - if you want to use UpdateOperation or a custom form operation that needs the entry; +- `:setup="function($crud, $parent) {}"` - if you want to make changes to the operation setup (eg. add/remove fields, configure functionality), you can use this parameter; the closure passed here will be run _after_ the setup of that operation had already completed; + +**Advanced example:** + +```html + +``` + +
+ ### Datatable @@ -92,7 +126,7 @@ These are the components that Backpack uses inside the default CRUD operations. Useful if you want to show the entries in the database, for an Eloquent model. This component shows a datatable _anywhere you want_, so the admin to easily list, filter, search and perform other operations on entries of an Eloquent model. The datatable component is a extension of a CrudController - so a CrudController for that entity needs to be already set up, and passed to this component as a parameter: ```html - + ``` **Configuration options:** @@ -104,7 +138,7 @@ Useful if you want to show the entries in the database, for an Eloquent model. T ```html ``` @@ -193,7 +227,7 @@ Your datalist will pick up the configuration in your CrudController automaticall ```html ``` From ff321f8392c3ea76d1acc12183cfe74270754096 Mon Sep 17 00:00:00 2001 From: Cristian Tabacitu Date: Tue, 24 Jun 2025 12:53:04 +0300 Subject: [PATCH 12/32] mention dataform widget --- 7.x-dev/base-widgets.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/7.x-dev/base-widgets.md b/7.x-dev/base-widgets.md index a1d1a5b..8652410 100644 --- a/7.x-dev/base-widgets.md +++ b/7.x-dev/base-widgets.md @@ -347,10 +347,27 @@ class ChartjsPieController extends ChartController ``` + +### Dataform + +Shows a dataform component from a particular CrudController. For more info about the configuration parameter, please see the [dataform component docs](/docs/{{version}}/base-components#dataform). + +```php +[ + 'type' => 'dataform', + 'controller' => 'App\Http\Controllers\Admin\InvoiceCrudController', + 'name' => 'invoice_form', + 'setup' => function($crud, $parent) { + // you can use this closure to modify your CrudController definition. + $crud->removeField('notes'); + } +] +``` +
-### DataTable +### Datatable Shows a datatable component from a particular CrudController. For more info about the configuration parameter, please see the [datatable component docs](/docs/{{version}}/base-components#datatable). @@ -360,7 +377,7 @@ Shows a datatable component from a particular CrudController. For more info abou 'controller' => 'App\Http\Controllers\Admin\PetShop\InvoiceCrudController', 'name' => 'invoices', 'setup' => function($crud, $parent) { - // you can use this closure to modify your CrudController definition. + // you can use this closure to modify your CrudController definition. if ($parent) { $crud->addClause('where', 'owner_id', $parent->id); } @@ -388,7 +405,7 @@ Allows you to include multiple widgets within a "div" element with the attribute ] ``` -Anything you specify on this widget, other than ```type``` and ```content```, has to be a string, and will be considered an attribute of the "div" element. +Anything you specify on this widget, other than ```type``` and ```content```, has to be a string, and will be considered an attribute of the "div" element. For example, in the following snippet, ```class``` and ```custom-attribute``` are attributes of the "div" element: ```php From 1cdcd74cf286c62a54e2dcdcbd59137c7efe5f15 Mon Sep 17 00:00:00 2001 From: Cristian Tabacitu Date: Wed, 25 Jun 2025 13:27:31 +0300 Subject: [PATCH 13/32] change general chip syntax, polish docs --- 7.x-dev/crud-chips.md | 127 +++++++++++++++++++++++++++--------------- 1 file changed, 83 insertions(+), 44 deletions(-) diff --git a/7.x-dev/crud-chips.md b/7.x-dev/crud-chips.md index 6f74c17..7d98919 100644 --- a/7.x-dev/crud-chips.md +++ b/7.x-dev/crud-chips.md @@ -5,13 +5,11 @@ ## About -A chips helps show the information of a database entry, in a format that takes up little space visually. +A chips helps show the information of a database entry, in a format that takes up little space visually. It can be used anywhere you want, but it's particularly useful inside operations to: +- show more info inside a table cell in the **ListOperation**; +- show a related item in more detail in the **ShowOperation**; -It can be used inside operations to: -- show more info inside a table cell in **ListOperation**; -- show a related item in more detail in **ShowOperation**; - -A chip consists of only one file - a blade file with the same name as the chip type (ex: ```general.blade.php```). Backpack provides you with one chip type, that is designed to accomodate many types of database entries, but you can easily [create an entirely new chip type](#creating-a-custom-chip-type). +A chip consists of only one file - a blade file with the same name as the chip type (ex: ```general.blade.php```). Backpack provides you with one chip type, that is very general (hence the name). This chip is designed to accomodate most types of database entries - but if your needs are more particular, you can easily [create an entirely new chip type](#creating-a-custom-chip-type). ### Default Chip Types @@ -19,33 +17,70 @@ A chip consists of only one file - a blade file with the same name as the chip t #### General Chip -// TODO: add image of general chip +![Backpack v7 general chip](https://backpackforlaravel.com/uploads/v7/general_chip.jpg) + +This chip was designed to be so general, that it's useful to show _most_ types of entries from the database. The general chip has 3 sections: `heading`, `image` and `details`. All sections are optional. Each of those sections has one mandatory attribute, `content`. Any other attributes you specify on those sections will be placed on that DOM element. -This chip was designed to be so general, that it's useful to show _most_ types of information from the database. +Here's a very minimal usage of the general chip: ```php @include('crud::chips.general', [ - 'text' => 'John Doe', - 'title' => 'Example of a chip without URL', - 'url' => 'https://google.com/', - 'target' => '_blank', - 'image' => asset('uploads/person1.jpg'), + 'heading' => [ + 'content' => 'John Doe', + ], + 'image' => [ + 'content' => asset('uploads/person1.jpg'), + ], 'details' => [ [ 'icon' => 'la la-hashtag', - 'text' => '8AH13A7', + 'content' => '8AH13A7', + ], + [ + 'icon' => 'la la-envelope', + 'content' => 'john.doe@example.com', + ], + [ + 'icon' => 'la la-phone', + 'content' => '+1 (555) 123-4567', + ] + ] +]) +``` + +But you can also specify more attributes, to enhance your chip with links, titles etc: + +```php +@include('crud::chips.general', [ + 'heading' => [ + 'content' => 'John Doe', + 'href' => 'https://google.com/', + 'target' => '_blank', + 'title' => 'Example of a chip without URL', + ], + 'image' => [ + 'content' => asset('uploads/person1.jpg'), + 'element' => 'a', + 'href' => 'https://chatgpt.com/', + 'target' => '_blank', + 'title' => 'Image can have its own URL, but why?! Falls back to the one in the heading', + ], + 'details' => [ + [ + 'icon' => 'la la-hashtag', + 'content' => '8AH13A7', 'url' => 'mailto:john.doe@example.com', 'title' => 'Click to email', ], [ 'icon' => 'la la-envelope', - 'text' => 'john.doe@example.com', + 'content' => 'john.doe@example.com', 'url' => 'mailto:john.doe@example.com', 'title' => 'Click to email', ], [ 'icon' => 'la la-phone', - 'text' => '+1 (555) 123-4567', + 'content' => '+1 (555) 123-4567', 'url' => 'tel:+15551234567', 'title' => 'Click to call', ] @@ -61,33 +96,38 @@ Depending on _where_ you want to use a chip, there are a few ways you can do tha #### How to use a chip inside a custom blade view -// TODO: image with chip inside a custom blade view - If you want to load a chip inside a custom page, custom component or anything else custom, you can just include the blade view directly, and pass whatever attributes you want to show. For example, if you want to use the `general` chip you can just include that blade file, and pass some of the variables it supports: ```php -{{-- Example of General chip for a person, with data from Eloquent model --}} +{{-- Example of General chip for a person, with data from a User model --}} @include('crud::chips.general', [ - 'text' => $user->name, - 'url' => backpack_url('http://github.com/user/'.$user-%3Eid.'/show'), - 'showImage' => false, - // 'image' => backpack_avatar_url(http://github.com/$user), // doesn't work well with dummy data + 'heading' => [ + 'content' => $user->name, + 'href' => backpack_url('http://github.com/user/'.$user-%3Eid.'/show'), + 'title' => 'Click to preview', + ], + 'image' => [ + 'content' => backpack_avatar_url(http://github.com/$user), // doesn't work well with dummy data + 'element' => 'a', + 'href' => backpack_url('http://github.com/user/'.$user-%3Eid.'/show'), + 'title' => 'Because of dummy data, this image is not available, but it would show a profile image', + ], 'details' => [ [ 'icon' => 'la la-hashtag', - 'text' => $user->id, + 'content' => $user->id, 'url' => backpack_url('http://github.com/user/'.$user-%3Eid.'/show'), 'title' => 'Click to preview', ], [ 'icon' => 'la la-envelope', - 'text' => $user->email, + 'content' => $user->email, 'url' => 'mailto:'.$user->email, 'title' => 'Click to email', ], [ 'icon' => 'la la-calendar', - 'text' => $user->created_at->format('F j, Y'), + 'content' => $user->created_at->format('F j, Y'), 'title' => 'Created at '.$user->created_at, ] ] @@ -97,9 +137,9 @@ If you want to load a chip inside a custom page, custom component or anything el #### How to use a chip as a datatable column -// TODO: image of CRUD before and after using chips in a Datatable +![Backpack v7 general chip in datatable component](https://backpackforlaravel.com/uploads/v7/general_chip_in_datatable_component.jpg) -When your datatables have too many columns, chips become very useful. They allow you to group multiple columns inside a chip, reducing the number of columns and thereby showing more information in less space. No longer will your admins have to expand the table row or use horizontal scrolling to see important info. +When your datatables have too many columns, chips become particularly useful. They allow you to compress the info from 5 or more columns... into a single chip column. This improves the UX of big datatables - your admins will no longer have to expand the table row or use horizontal scrolling to see crucial info. Remember, a chip is just a simple blade file. So to use a chip as a column, we can just use the `view` column type, and pass the path to our chip file. For example: @@ -117,7 +157,7 @@ By default, the view column type is not searchable. In order to make your chip c #### How to use a chip as a widget -// TODO: image with chip as a widget +![Backpack v7 general chip as widget](https://backpackforlaravel.com/uploads/v7/general_chip_as_widget.jpg) Chip files usually only contain the minimum content and styling necessary. You can include them as widgets directly, but they probably won't look very pretty on a custom page, because they don't have a background, borders, shadow etc. That's why we've also created a `chip` widget, which adds wrappers just like the other widgets - so that your chip will look good when placed on a custom page (or an existing CRUD page, why not). @@ -137,7 +177,7 @@ Widget::add() ## Overwriting Default Chip Types -You can overwrite a chip type by placing a file with the same name in your ```resources\views\vendor\backpack\crud\chips``` directory. But it is NOT recommended to do so. When you're overwriting a default chip type, you're forfeiting any future updates for that chip. We can't push updates to a file that you're no longer using. +You can override a chip by create a file in ```resources\views\vendor\backpack\crud\chips``` with the same name. But it is NOT recommended to override the `general` chip type. When you do that, you're forfeiting any future updates for that chip. We can't push updates to a file that you're no longer using. In 99.9% of the cases, it's recommended NOT to override the default `general` chip file, but to create a _custom_ chip file. That will make it a lot easier to upgrade to newer versions of Backpack - because the file is completely in your control. @@ -148,7 +188,6 @@ In 99.9% of the cases, it's recommended NOT to override the default `general` ch Chips consist of only one file - a blade file with the same name as the chip type (ex: ```person.blade.php```). You can create one by placing a new blade file inside ```resources\views\vendor\backpack\crud\chips```. Be careful to choose a distinctive name - usually the model name works best. -// TODO: create this command To create a new chip file in the standard directory, you can run `php artisan backpack:chip {chip-file-name}`. This will create a new file in that directory, from a stub, for you to customize however you want. For example, you can do `php artisan backpack:chip person` to create a ```person.blade.php``` then includes the HTML content directly: @@ -195,28 +234,28 @@ But most likely, you'll want to create a chip that outputs some information for @endphp @include('crud::chips.general', [ - 'text' => $entry->name, - 'url' => backpack_url('http://github.com/pet-shop/owner/'.$entry-%3Eid.'/show'), - 'image' => asset($entry->avatar->url), - // 'showImage' => false, + 'heading' => [ + 'content' => 'Invoice '.$entry->series.' '.$entry->number.' - '.$entry->owner->name, + 'href' => backpack_url('http://github.com/pet-shop/invoice/'.$entry-%3Eid.'/show'), + ], 'details' => [ [ - 'icon' => 'la la-dog', - 'text' => $entry->pets->count().' pets', - 'title' => 'Number of pets: '.$entry->pets->count(), + 'icon' => 'la la-dollar', + 'content' => $entry->total, + 'title' => 'Total invoice amount $'.$entry->total, ], [ - 'icon' => 'la la-shopping-cart', - 'text' => $entry->invoices->count(). ' purchases', - 'title' => 'Number of purchases: '.$entry->invoices->count(), + 'icon' => 'la la-tags', + 'content' => $entry->items->count().' items', ], [ 'icon' => 'la la-calendar', - 'text' => $last_purchase->format('F j, Y'), - 'title' => 'Last purchase: '.$last_purchase, + 'content' => $last_purchase->format('F j, Y'), + 'title' => 'Issuance date: '.$last_purchase, ] ] ]) + ``` -Otherwise, you can create a completely custom chip, that looks and works differently from the `general` chip. There are no limitations - since chips are simple blade files. +Otherwise, you can create a completely custom chip, that looks and works differently from the `general` chip. There are no limitations - since chips are simple blade files. Just copy-paste the HTML from the `general` chip and change it to match your needs. Or add completely different HTML - there are no limitations. From 07d8bc2e7699c24b18a672cbd50a282c2e83e26f Mon Sep 17 00:00:00 2001 From: Cristian Tabacitu Date: Wed, 25 Jun 2025 13:57:17 +0300 Subject: [PATCH 14/32] better docs for chip command --- 7.x-dev/crud-chips.md | 78 +++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/7.x-dev/crud-chips.md b/7.x-dev/crud-chips.md index 7d98919..14e363f 100644 --- a/7.x-dev/crud-chips.md +++ b/7.x-dev/crud-chips.md @@ -152,7 +152,12 @@ CRUD::addColumn([ 'view' => 'crud::chips.invoice', ]); ``` -By default, the view column type is not searchable. In order to make your chip columns searchable you need to [specify a custom ```searchLogic``` in your declaration](/docs/{{version}}/crud-columns#custom-search-logic). + +Now create that blade file, by running `php artisan backpack:chip invoice`. This will create a file in `resources/views/admin/chips` for you to edit, and customize as you like. By default, it just uses the `$entry` variable (which will be present if you use it as a column). You can include the `general` chip view if it's good enough for you, or copy-paste the HTML from the `general` chip, and modify it to your liking (you can run `php artisan backpack:chip invoice --from=general` to create a chip with all the HTML from general). + +Please note: +- By default, the view column type is not searchable. In order to make your chip columns searchable you need to [specify a custom ```searchLogic``` in your declaration](/docs/{{version}}/crud-columns#custom-search-logic). +- By default, the view column type is not orderable. In order to make your chip columns orderable you need to [specify a custom ```orderLogic``` in your declaration](/docs/{{version}}/crud-columns#custom-order-logic). #### How to use a chip as a widget @@ -188,9 +193,42 @@ In 99.9% of the cases, it's recommended NOT to override the default `general` ch Chips consist of only one file - a blade file with the same name as the chip type (ex: ```person.blade.php```). You can create one by placing a new blade file inside ```resources\views\vendor\backpack\crud\chips```. Be careful to choose a distinctive name - usually the model name works best. -To create a new chip file in the standard directory, you can run `php artisan backpack:chip {chip-file-name}`. This will create a new file in that directory, from a stub, for you to customize however you want. +To create a new chip file in the standard directory, you can run: +- `php artisan backpack:chip {chip-name}` to create a new file in that directory, from our stub that assumes you want to use that chip inside the ListOperation and ShowOperation, so you'll be using the `$entry` variable to define what you want the chip to include; +- `php artisan backpack:chip {chip-name} --from=general` to create a new file in that directory, from our `general` chip, so you can change the HTML however you want; + +For example, you can do `php artisan backpack:chip invoice` to create ```invoice.blade.php``` that helps you define what that chips includes: + +```php +@php + $last_purchase = $entry->invoices()->orderBy('issuance_date', 'DESC')->first()->issuance_date; +@endphp + +@include('crud::chips.general', [ + 'heading' => [ + 'content' => 'Invoice '.$entry->series.' '.$entry->number.' - '.$entry->owner->name, + 'href' => backpack_url('http://github.com/pet-shop/invoice/'.$entry-%3Eid.'/show'), + ], + 'details' => [ + [ + 'icon' => 'la la-dollar', + 'content' => $entry->total, + 'title' => 'Total invoice amount $'.$entry->total, + ], + [ + 'icon' => 'la la-tags', + 'content' => $entry->items->count().' items', + ], + [ + 'icon' => 'la la-calendar', + 'content' => $last_purchase->format('F j, Y'), + 'title' => 'Issuance date: '.$last_purchase, + ] + ] +]) +``` -For example, you can do `php artisan backpack:chip person` to create a ```person.blade.php``` then includes the HTML content directly: +But you can also run `php artisan backpack:chip custom --from=general`, wipe everything inside the generated file, and include your own custom HTML, hardcoded or not: ```html
@@ -226,36 +264,4 @@ For example, you can do `php artisan backpack:chip person` to create a ```person
``` -But most likely, you'll want to create a chip that outputs some information for a particular database entry. If you like how the `general` chip looks, and only want to make it easy to re-use the chip, you can create a chip that includes the `general` chip. For example: - -```php -@php - $last_purchase = $entry->invoices()->orderBy('issuance_date', 'DESC')->first()->issuance_date; -@endphp - -@include('crud::chips.general', [ - 'heading' => [ - 'content' => 'Invoice '.$entry->series.' '.$entry->number.' - '.$entry->owner->name, - 'href' => backpack_url('http://github.com/pet-shop/invoice/'.$entry-%3Eid.'/show'), - ], - 'details' => [ - [ - 'icon' => 'la la-dollar', - 'content' => $entry->total, - 'title' => 'Total invoice amount $'.$entry->total, - ], - [ - 'icon' => 'la la-tags', - 'content' => $entry->items->count().' items', - ], - [ - 'icon' => 'la la-calendar', - 'content' => $last_purchase->format('F j, Y'), - 'title' => 'Issuance date: '.$last_purchase, - ] - ] -]) - -``` - -Otherwise, you can create a completely custom chip, that looks and works differently from the `general` chip. There are no limitations - since chips are simple blade files. Just copy-paste the HTML from the `general` chip and change it to match your needs. Or add completely different HTML - there are no limitations. +Otherwise, you can create a completely custom chip, that looks and works differently from the `general` chip, and re-use that in your application. There are no limitations - since chips are simple blade files. Just copy-paste the HTML from the `general` chip and change it to match your needs. From 7ad8a047f11a3dc57473de95b410ca1f79d9d127 Mon Sep 17 00:00:00 2001 From: Cristian Tabacitu Date: Wed, 25 Jun 2025 13:59:56 +0300 Subject: [PATCH 15/32] note about eager loading --- 7.x-dev/crud-chips.md | 1 + 1 file changed, 1 insertion(+) diff --git a/7.x-dev/crud-chips.md b/7.x-dev/crud-chips.md index 14e363f..4f571ba 100644 --- a/7.x-dev/crud-chips.md +++ b/7.x-dev/crud-chips.md @@ -156,6 +156,7 @@ CRUD::addColumn([ Now create that blade file, by running `php artisan backpack:chip invoice`. This will create a file in `resources/views/admin/chips` for you to edit, and customize as you like. By default, it just uses the `$entry` variable (which will be present if you use it as a column). You can include the `general` chip view if it's good enough for you, or copy-paste the HTML from the `general` chip, and modify it to your liking (you can run `php artisan backpack:chip invoice --from=general` to create a chip with all the HTML from general). Please note: +- If your chip uses any info from RELATED items, you should probably eager load those items. For example if you're in an InvoiceCrudController you could do this in your `setupListOperation()` or hell maybe even in setup(): `CRUD::with(['event', 'event.production', 'event.venue', 'event.venue.city']);` - that way when your chip needs that info, it already has it onpage, and makes no extra queries; - By default, the view column type is not searchable. In order to make your chip columns searchable you need to [specify a custom ```searchLogic``` in your declaration](/docs/{{version}}/crud-columns#custom-search-logic). - By default, the view column type is not orderable. In order to make your chip columns orderable you need to [specify a custom ```orderLogic``` in your declaration](/docs/{{version}}/crud-columns#custom-order-logic). From 67a63d5ae7913607fb85747f8b057f43e74fb1a8 Mon Sep 17 00:00:00 2001 From: Cristian Tabacitu Date: Thu, 26 Jun 2025 20:44:36 +0300 Subject: [PATCH 16/32] polish v7 installation, release notes and upgrade guide before beta launch --- 7.x-dev/installation.md | 13 ++++-- 7.x-dev/release-notes.md | 85 ++++++++++++++++++++++++++++------------ 7.x-dev/upgrade-guide.md | 46 +++++++++++----------- 3 files changed, 94 insertions(+), 50 deletions(-) diff --git a/7.x-dev/installation.md b/7.x-dev/installation.md index 8fc6859..b6e6197 100644 --- a/7.x-dev/installation.md +++ b/7.x-dev/installation.md @@ -5,11 +5,11 @@ ## Requirements -If you can run Laravel 10 or 11, you can install Backpack. Backpack does _not_ have additional requirements. +If you can run Laravel 12, you can install Backpack. Backpack does _not_ have additional requirements. For the following process, we assume: -- you have a [working installation of Laravel](https://laravel.com/docs/11.x#installation) (an existing project is fine, you don't need a *fresh* Laravel install); +- you have a [working installation of Laravel](https://laravel.com/docs/12.x#installation) (an existing project is fine, you don't need a *fresh* Laravel install); - you have configured your .ENV file with your database and mail information; @@ -24,7 +24,14 @@ For the following process, we assume: Go to your Laravel project's directory, then in your terminal, run: ``` bash -composer require backpack/crud +# during beta, configure your Composer.json to accept unstable version, by running: +composer config minimum-stability dev +composer config prefer-stable true + +# then require the v7-beta: +composer require backpack/crud:"^7.0@dev" + +# and finally, install Backpack: php artisan backpack:install ``` diff --git a/7.x-dev/release-notes.md b/7.x-dev/release-notes.md index 664e774..e6555e9 100644 --- a/7.x-dev/release-notes.md +++ b/7.x-dev/release-notes.md @@ -2,34 +2,64 @@ --- -**Planned launch date:** Dec 4th, 2024 +**Planned launch date:** August 1st, 2025 -For the past 2 years, we've done our very best to make all changes to Backpack in a backwards-compatible way. To not push a new version, because we know it's a pain in the bee's hind to upgrade stuff. But... it's time for a new release. Have no fear though, we've made this super easy for you. +For the past 2.5 years, we've done our very best to make all changes to Backpack in a backwards-compatible way. To not push a new version, because we know it's a pain to upgrade stuff. But... it's time for a new release. Have no fear though, we've made this super easy for you - and the new features & bug fixes are worth it! -Backpack v7 is a maintenance release. Yes, it does have a few breaking changes, but they will not impact 99.9% of projects. But that doesn't mean you shouldn't follow the upgrade guide! Please do - read it from top to bottom and make sure none of the changes impact you. +Here are the BIG things Backpack v7 brings to the table and why you should upgrade from [Backpack v6](/docs/6.x) to v7. But first... we should give credit where credit is due. **Big BIG thanks to our team: [Pedro Martins](https://github.com/pxpm), [Jorge Castro](https://github.com/jcastroa87)**, [Karan Datwani](https://github.com/karandatwani92)** and [Cristian Tabacitu](https://github.com/tabacitu) for working on this new version - and of course **our paying customers**, who have made all of this possible by supporting our work 🙏 -Here are the BIG things Backpack v7 brings to the table and why you should upgrade from [Backpack v6](/docs/6.x) to v7. But first... we should give credit where credit is due. **Big BIG thanks to**: -- **[Pedro Martins](https://github.com/pxpm)** for x; -- **[Jorge Castro](https://github.com/jcastroa87)** for y; -- **[Karan Datwani](https://github.com/karandatwani92)** for z; -- **[Cristian Tabacitu](https://github.com/tabacitu)** for t; -- **our paying customers**, who have made all of this possible by supporting our work 🙏 - -Together, our team has put in an incredible amount of work to make v7 what it is - more than XXX commits, across YYY months, all while still maintaining, bug fixing and improving v6. Again, big thanks to everybody who has helped made this happen 🙏 +Together, our team has put in an incredible amount of work to make v7 what it is - more than 1000 commits, across more than 8 months, all while still maintaining, bug fixing and improving v6. Again, big thanks to everybody who has helped made this happen - and of course, BIG thanks to our beta testers 🙏 ## Added -### CRUD Lifecycle Hooks +### Data Components -Previously when working with Operations, developers found themselves needing to _override_ an entire operation method, in order to do things before/after the routes/defaults/operation is set up. This created a lot of duplicate code, and made it hard to maintain. Now, you can use CRUD Lifecycle Hooks to add your own code before/after each operation method. This is a much cleaner way to add your own code, without having to override the entire method. [Read more](/docs/{{version}}/crud-operations#lifecycle-hooks). +Our team has spend a lot of time and effort to make it possible to include the content of our main operations... anywhere you want. In the process, we've not only bent the laws of physics (ok maybe only PHP), but also made those operations _cleaner_. + +#### Datatable component + +![Datatable component in Backpack for Laravel v7](https://backpackforlaravel.com/uploads/v7/datatable_component.jpg) + +You can now include a datatable anywhere you want! Just use the component in your custom views, custom pages or custom operations - it will pick up all the setup from your existing CrudController. [Read more](/docs/{{version}}/base-components#datatable-1). + +#### Dataform component + +![Dataform component in Backpack for Laravel v7](https://backpackforlaravel.com/uploads/v7/dataform_component.jpg) + +You can now include a form anywhere you want! Same as the datatable - just use the component in your custom blade files, and it will pick up the fields from your CrudController. [Read more](/docs/{{version}}/base-components#dataform-component). + +#### Datalist component + +![Datalist component in Backpack for Laravel v7](https://backpackforlaravel.com/uploads/v7/datalist_component.jpg) + +You can now use the content of the Show page for a particular entry... anywhere you want. It's as simple as loading the component and passing the CrudController. [Read more](/docs/{{version}}/base-components#datalist-component). + +#### Datagrid component + +![Datagrid component in Backpack for Laravel v7](https://backpackforlaravel.com/uploads/v7/datagrid_component.jpg) + +Our previous design for the Show operation worked fine... but it wasn't pretty. We've developed an alternative comopnent, so that your Show operation looks a little better - just specify you want the show operation to use `datagrid` in your `config/backpack/operations/show.php`. Of course... you can also use it (you guessed it)... anywhere you want. It's as simple as loading the component and passing the CrudController. [Read more](/docs/{{version}}/base-components#datagrid-component). -### Two-Factor Authentication +### Chips -// TODO +![Chips in Backpack v7](https://backpackforlaravel.com/uploads/v7/general_chip.jpg) -### Re-Usable Filters +You know columns, you know fields - please welcome... chips! A chips helps show the information of a database entry, in a format that takes up little space visually. It can be used anywhere you want, but it's particularly useful inside the Show and List operations, to cram as much info as possible in as little space as possible. [Read more](/docs/{{version}}/crud-chips). +### Skins + +![Chips in Backpack v7](https://backpackforlaravel.com/uploads/v7/glass_skin.jpg) + +It's been 2.5 years since we've adopted Tabler as our default HTML template - and in this time, we have only grown more fond of it. We are truly convinced that it's the best free Bootstrap template for admin panels, and our partnership and commitment has only grown. This new version of Backpack comes with a new feature inside our Tabler theme... skins. + +Skins are a simple CSS file, that you can enable/not, to give your admin panel a completely different look. We're launching with one modern skin (that we call "non-liquid glass"). Soon enough, we'll follow up with a few more skins and... a way for you to _quickly_ create a custom skin, that will match your brand colors. + +### CRUD Lifecycle Hooks + +Previously when working with Operations, developers found themselves needing to _override_ an entire operation method, in order to do things before/after the routes/defaults/operation is set up. This created a lot of duplicate code, and made it hard to maintain. Now, you can use CRUD Lifecycle Hooks to add your own code before/after each operation method. This is a much cleaner way to add your own code, without having to override the entire method. [Read more](/docs/{{version}}/crud-operations#lifecycle-hooks). + +### Re-usable Filters - Inside Custom Pages or Operations ![](https://backpackforlaravel.com/uploads/docs/filters/filters-in-custom-page.png) @@ -39,29 +69,34 @@ Starting with this Backpack version, you can use the [filters](/docs/{{version}} Filters can now be used inside [Custom Views for your List operation](https://backpackforlaravel.com/docs/{{version}}/crud-operation-list-entries#custom-views-for-listoperation-pro). This means once the admin has selected the Custom View, they can further drill down in the list, using the filters. But not only that... you can _remove_ the general filters and add entirely new filters, just for that Custom View. -### Browser Tests - -// TODO - - ## Changed +### New Versions for All Assets + +We've bumped the version of ALL javascript and CSS assets we have, across the board. By upgrading to Backpack v7, you're automatically getting the best they have to offer - including Tabler, Bootstrap, Datatables etc. + ### Uploaders -// TODO +We've ironed out all the quirks of Uploaders (and uploaders inside repeatables etc). This needed a few small breaking changes, but nothing that should affect you, if you haven't created custom uploaders. Try them again - they should all work fine now! ### Moved TinyMCE and CKEditor fields & columns -// TODO +We've moved the TinyMCE & CKeditor fields & columns from PRO to their own addons - released under open-source licenses. Please note that the underlying JS libraries are under GPLv2 license - which means you should not use them inside paid projects without purchasing a license from their respective creators. ### Basset -// TODO +A revolution in how easy it is to load CSS and JS assets in PHP, but we found out the hard way that making things easy is... _hard_. We're glad to tell you we've finally fixed most problems that came with Basset - and it's more reliable than ever. Additionally, you can now: +- name your assets, to easily use the same asset in multiple places; +- publish the assetmap, to override assets from vendor packages; +- use Basset on localhost (to code without an internet connection); +- store your assets in Git, so there's zero need to run basset in production; + +For more information, check out [the docs for Basset's next version](https://github.com/Laravel-Backpack/basset/tree/next). ### Parent Theme -// TODO +// TODO: docs ## Removed diff --git a/7.x-dev/upgrade-guide.md b/7.x-dev/upgrade-guide.md index b48b3ed..f16d003 100644 --- a/7.x-dev/upgrade-guide.md +++ b/7.x-dev/upgrade-guide.md @@ -4,6 +4,8 @@ This will guide you to upgrade from Backpack v6 to v7. The steps are color-coded by the probability that you will need it for your application: High, Medium and Low. **At the very least, please read what's in bold**. +> IMPORTANT NOTE: This upgrade guide is NOT AT ALL final. We do not recommend you upgrade your existing project to v7. We're working on making the upgrade process easier for you. We will let you know when this changes. + ## Requirements @@ -26,7 +28,7 @@ Please make sure your project respects the requirements below, before you start ## Upgrade Steps -Step 0. **[Upgrade to Laravel 11](https://laravel.com/docs/11.x/upgrade) if you don't use it yet, then test to confirm your app is working fine.** +Step 0. **[Upgrade to Laravel 12](https://laravel.com/docs/12.x/upgrade) if you don't use it yet, then test to confirm your app is working fine.** ### Composer @@ -34,29 +36,29 @@ Please make sure your project respects the requirements below, before you start Step 1. Update your ```composer.json``` file to require: ``` - "backpack/crud": "v7-dev", + "backpack/crud": "^7.0@dev", ``` Step 2. Bump the version of any first-party Backpack add-ons you have installed (eg. `backpack/pro`, `backpack/editable-columns` etc.) to the versions that support Backpack v6. For 3rd-party add-ons, please check each add-on's Github page. Here's a quick list of 1st party packages and versions: ```js - "backpack/crud": "v7-dev", - "backpack/pro": "v3-dev", - "backpack/filemanager": "^3.0", - "backpack/theme-coreuiv2": "^1.0", - "backpack/theme-coreuiv4": "^1.0", - "backpack/theme-tabler": "^1.0", - "backpack/logmanager": "^5.0", - "backpack/settings": "^3.1", - "backpack/newscrud": "^5.0", - "backpack/permissionmanager": "^7.0", - "backpack/pagemanager": "^3.2", - "backpack/menucrud": "^4.0", - "backpack/backupmanager": "^5.0", - "backpack/editable-columns": "^3.0", - "backpack/revise-operation": "^2.0", - "backpack/medialibrary-uploaders": "^1.0", - "backpack/devtools": "^2.0", + "backpack/crud": "dev-next", + "backpack/pro": "dev-next", + "backpack/filemanager": "dev-next", + "backpack/theme-coreuiv2": "dev-next", + "backpack/theme-coreuiv4": "dev-next", + "backpack/theme-tabler": "dev-next", + "backpack/logmanager": "dev-next", + "backpack/settings": "dev-next", + "backpack/newscrud": "dev-next", + "backpack/permissionmanager": "dev-next", + "backpack/pagemanager": "dev-next", + "backpack/menucrud": "dev-next", + "backpack/backupmanager": "dev-next", + "backpack/editable-columns": "dev-next", + "backpack/revise-operation": "dev-next", + "backpack/medialibrary-uploaders": "dev-next", + "backpack/devtools": "dev-next", ``` Step 3. Let's get the latest Backpack and install it. If you get any conflicts with **Backpack 1st party add-ons**, most of the time you just need to move one version up, eg: from `backpack/menucrud: ^3.0` to `backpack/menucrud: ^4.0`. See the step above again. Please run: @@ -109,10 +111,10 @@ No changes needed. ### Views -**List Operation View** - The List Operation view got a huge change. We decoupled the datatable from the view, so that you can use the table anywhere you would like. -Most of the code is still identical but moved to `datatable.blade.php`. The `list.blade.php` view now only includes the mentioned datatable component. +**List Operation View** - The List Operation view got a huge change. We decoupled the datatable from the view, so that you can use the table anywhere you would like. +Most of the code is still identical but moved to `datatable.blade.php`. The `list.blade.php` view now only includes the mentioned datatable component. -If you had customized the `list.blade.php` you should move your customizations to `datatable.blade.php`. +If you had customized the `list.blade.php` you should move your customizations to `datatable.blade.php`. ### Security From 37491c853ee8052bab6d93f3b58e39e8d8da5eaf Mon Sep 17 00:00:00 2001 From: flartet Date: Mon, 30 Jun 2025 10:47:02 +0200 Subject: [PATCH 17/32] Update crud-columns.md bad field in join --- 6.x/crud-columns.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/6.x/crud-columns.md b/6.x/crud-columns.md index 062e92d..1ba20aa 100644 --- a/6.x/crud-columns.md +++ b/6.x/crud-columns.md @@ -1542,7 +1542,7 @@ $this->crud->addColumn([ 'attribute' => 'name', // foreign key attribute that is shown to user 'orderable' => true, 'orderLogic' => function ($query, $column, $columnDirection) { - return $query->leftJoin('categories', 'categories.id', '=', 'articles.select') + return $query->leftJoin('categories', 'categories.id', '=', 'articles.category_id') ->orderBy('categories.name', $columnDirection)->select('articles.*'); } ]); From d1f93c3ff613c901d21659ce49632d0b5d68889b Mon Sep 17 00:00:00 2001 From: Pedro Martins Date: Tue, 1 Jul 2025 10:49:39 +0100 Subject: [PATCH 18/32] Update crud-columns.md in v7 to match v6 docs --- 7.x-dev/crud-columns.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/7.x-dev/crud-columns.md b/7.x-dev/crud-columns.md index 63478d3..93986ef 100644 --- a/7.x-dev/crud-columns.md +++ b/7.x-dev/crud-columns.md @@ -1498,7 +1498,7 @@ $this->crud->addColumn([ 'attribute' => 'name', // foreign key attribute that is shown to user 'orderable' => true, 'orderLogic' => function ($query, $column, $columnDirection) { - return $query->leftJoin('categories', 'categories.id', '=', 'articles.select') + return $query->leftJoin('categories', 'categories.id', '=', 'articles.category_id') ->orderBy('categories.name', $columnDirection)->select('articles.*'); } ]); From 6c46df2e576b77077f9889bc65342fb811006c2f Mon Sep 17 00:00:00 2001 From: Mohammad Emran Date: Wed, 2 Jul 2025 07:23:46 +0600 Subject: [PATCH 19/32] Update links to larave.com docs --- 6.x/base-how-to.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/6.x/base-how-to.md b/6.x/base-how-to.md index 4b8efe3..3e13613 100644 --- a/6.x/base-how-to.md +++ b/6.x/base-how-to.md @@ -51,7 +51,7 @@ In order to place something else inside that view, like [widgets](/docs/{{versio ``` To use information from the database, you can: -- [use view composers](https://laravel.com/docs/5.7/views#view-composers) to push variables inside this view, when it's loaded; +- [use view composers](https://laravel.com/docs/views#view-composers) to push variables inside this view, when it's loaded; - load all your dashboard information using AJAX calls, if you're loading charts, reports, etc, and the DB queries might take a long time; - use the full namespace for your models, like ```\App\Models\Product::count()```; @@ -290,7 +290,7 @@ This is a default in Backpack v4. Backpack's authentication uses a completely separate authentication driver, provider, guard and password broker. They're all named ```backpack```, and registered in the vendor folder, invisible to you. -If you need a separate login for user, just go ahead and create it. [Add the Laravel authentication, like instructed in the Laravel documentation](https://laravel.com/docs/5.7/authentication#authentication-quickstart): ```php artisan make:auth```. You'll then have: +If you need a separate login for user, just go ahead and create it. [Add the Laravel authentication, like instructed in the Laravel documentation](https://laravel.com/docs/authentication#authentication-quickstart): ```php artisan make:auth```. You'll then have: - the user login at ```/login``` -> using the AuthenticationController Laravel provides - the admin login at ```/admin/login``` -> using the AuthenticationControllers Backpack provides @@ -440,7 +440,7 @@ This will make the registration process pick up a view you can create, in ```res In Backpack CRUD 6.2 we introduced the ability to require email verification when accessing Backpack routes. To enable this feature please do the following: -**Step 1** - Make sure your user model (usually `App\Models\User`) implements the `Illuminate\Contracts\Auth\MustVerifyEmail` contract. [More info](https://laravel.com/docs/10.x/verification#model-preparation). +**Step 1** - Make sure your user model (usually `App\Models\User`) implements the `Illuminate\Contracts\Auth\MustVerifyEmail` contract. [More info](https://laravel.com/docs/verification#model-preparation). ```php Date: Thu, 3 Jul 2025 09:21:27 +0600 Subject: [PATCH 20/32] Update links to Laravel docs --- 7.x-dev/base-how-to.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/7.x-dev/base-how-to.md b/7.x-dev/base-how-to.md index 4b8efe3..3e13613 100644 --- a/7.x-dev/base-how-to.md +++ b/7.x-dev/base-how-to.md @@ -51,7 +51,7 @@ In order to place something else inside that view, like [widgets](/docs/{{versio ``` To use information from the database, you can: -- [use view composers](https://laravel.com/docs/5.7/views#view-composers) to push variables inside this view, when it's loaded; +- [use view composers](https://laravel.com/docs/views#view-composers) to push variables inside this view, when it's loaded; - load all your dashboard information using AJAX calls, if you're loading charts, reports, etc, and the DB queries might take a long time; - use the full namespace for your models, like ```\App\Models\Product::count()```; @@ -290,7 +290,7 @@ This is a default in Backpack v4. Backpack's authentication uses a completely separate authentication driver, provider, guard and password broker. They're all named ```backpack```, and registered in the vendor folder, invisible to you. -If you need a separate login for user, just go ahead and create it. [Add the Laravel authentication, like instructed in the Laravel documentation](https://laravel.com/docs/5.7/authentication#authentication-quickstart): ```php artisan make:auth```. You'll then have: +If you need a separate login for user, just go ahead and create it. [Add the Laravel authentication, like instructed in the Laravel documentation](https://laravel.com/docs/authentication#authentication-quickstart): ```php artisan make:auth```. You'll then have: - the user login at ```/login``` -> using the AuthenticationController Laravel provides - the admin login at ```/admin/login``` -> using the AuthenticationControllers Backpack provides @@ -440,7 +440,7 @@ This will make the registration process pick up a view you can create, in ```res In Backpack CRUD 6.2 we introduced the ability to require email verification when accessing Backpack routes. To enable this feature please do the following: -**Step 1** - Make sure your user model (usually `App\Models\User`) implements the `Illuminate\Contracts\Auth\MustVerifyEmail` contract. [More info](https://laravel.com/docs/10.x/verification#model-preparation). +**Step 1** - Make sure your user model (usually `App\Models\User`) implements the `Illuminate\Contracts\Auth\MustVerifyEmail` contract. [More info](https://laravel.com/docs/verification#model-preparation). ```php Date: Tue, 22 Jul 2025 14:25:01 +0100 Subject: [PATCH 21/32] update upgrade guide --- 7.x-dev/upgrade-guide.md | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/7.x-dev/upgrade-guide.md b/7.x-dev/upgrade-guide.md index 3ffd213..e6cc40f 100644 --- a/7.x-dev/upgrade-guide.md +++ b/7.x-dev/upgrade-guide.md @@ -42,8 +42,8 @@ Please make sure your project respects the requirements below, before you start Step 2. Bump the version of any first-party Backpack add-ons you have installed (eg. `backpack/pro`, `backpack/editable-columns` etc.) to the versions that support Backpack v6. For 3rd-party add-ons, please check each add-on's Github page. Here's a quick list of 1st party packages and versions: ```js - "backpack/crud": "dev-next", - "backpack/pro": "dev-next", + "backpack/crud": "^7.0@dev", + "backpack/pro": "^3.0@dev", "backpack/filemanager": "dev-next", "backpack/theme-coreuiv2": "dev-next", "backpack/theme-coreuiv4": "dev-next", @@ -91,7 +91,19 @@ No changes needed. ### Config -No changes needed. +**Theme Tabler** - The default layout for theme tabler has changed. If you had the tabler config published you are good to go. **In case you don't have the tabler theme config published** and want to keep the old layout, you should publish it by running `php artisan vendor:publish --tag="theme-tabler-config"` and changing: +```diff +- 'layout' => 'horizontal', ++ 'layout' => 'horizontal_overlap', +``` +You should also remove the glass skin and fuzzy background from the theme styles: +```diff +'styles' => [ + base_path('vendor/backpack/theme-tabler/resources/assets/css/skins/backpack-color-palette.css'), +- base_path('vendor/backpack/theme-tabler/resources/assets/css/skins/glass.css'), +- base_path('vendor/backpack/theme-tabler/resources/assets/css/skins/fuzzy-background.css'), + ], +``` ### CrudControllers @@ -106,7 +118,7 @@ No changes needed. ### CSS & JS Assets -No changes needed. + ### Views @@ -143,9 +155,10 @@ If the table view still looks wonky (search bar out of place, big + instead of e ### Upgrade Add-ons -For any addons you might have upgraded, please double-check if they have an upgrade guide. For example: -- Xx package has the upgrade guide here; -- Yy package has the upgrade guide here; +**backpack/file-manager** Using the File Manager package? Most of the views that weren't in use were removed, and the dependencies were bumped. If you didn't do any customization you should delete the `resources/views/vendor/elfinder` (`rm -rf resources/views/vendor/elfinder`) folder. +No need to publish any views anymore if you are not customizing them. If you were, publish the new view files (`php artisan vendor:publish --provider="Backpack\FileManager\FileManagerServiceProvider" --tag="elfinder-views"`). Then apply your customization on the new files, now located at: `resources/views/vendor/backpack/filemanager/` + +Additional the `browse` and `browse_multiple` **fields/columns** are now part of this package. If you previously made any modifications to this fields/columns you should publish the new views (`php artisan vendor:publish --provider="Backpack\FileManager\FileManagerServiceProvider" --tag="filemanger-fields"` and `php artisan vendor:publish --provider="Backpack\FileManager\FileManagerServiceProvider" --tag="filemanager-columns"`), and carry over the modifications from the old files to this new files. --- From 4c90b08674972c3eff3dfd7f0016b18e88f46e29 Mon Sep 17 00:00:00 2001 From: Karan Datwani Date: Wed, 23 Jul 2025 17:54:24 +0530 Subject: [PATCH 22/32] Add "backpack/generators": "dev-next", --- 7.x-dev/upgrade-guide.md | 1 + 1 file changed, 1 insertion(+) diff --git a/7.x-dev/upgrade-guide.md b/7.x-dev/upgrade-guide.md index e6cc40f..a8c677e 100644 --- a/7.x-dev/upgrade-guide.md +++ b/7.x-dev/upgrade-guide.md @@ -59,6 +59,7 @@ Please make sure your project respects the requirements below, before you start "backpack/revise-operation": "dev-next", "backpack/medialibrary-uploaders": "dev-next", "backpack/devtools": "dev-next", + "backpack/generators": "dev-next", ``` Step 3. Let's get the latest Backpack and install it. If you get any conflicts with **Backpack 1st party add-ons**, most of the time you just need to move one version up, eg: from `backpack/menucrud: ^3.0` to `backpack/menucrud: ^4.0`. See the step above again. Please run: From c5c50dfae2cdd4e4c48f6db32dfabd1728a152ff Mon Sep 17 00:00:00 2001 From: Karan Datwani Date: Wed, 23 Jul 2025 21:54:03 +0530 Subject: [PATCH 23/32] note --- 7.x-dev/upgrade-guide.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/7.x-dev/upgrade-guide.md b/7.x-dev/upgrade-guide.md index a8c677e..3317f72 100644 --- a/7.x-dev/upgrade-guide.md +++ b/7.x-dev/upgrade-guide.md @@ -62,6 +62,8 @@ Please make sure your project respects the requirements below, before you start "backpack/generators": "dev-next", ``` +> **Note:** To install Backpack v7 beta and its add-ons, set `"minimum-stability": "beta"` in your `composer.json`. + Step 3. Let's get the latest Backpack and install it. If you get any conflicts with **Backpack 1st party add-ons**, most of the time you just need to move one version up, eg: from `backpack/menucrud: ^3.0` to `backpack/menucrud: ^4.0`. See the step above again. Please run: ```bash @@ -92,7 +94,7 @@ No changes needed. ### Config -**Theme Tabler** - The default layout for theme tabler has changed. If you had the tabler config published you are good to go. **In case you don't have the tabler theme config published** and want to keep the old layout, you should publish it by running `php artisan vendor:publish --tag="theme-tabler-config"` and changing: +**Theme Tabler** - The default layout for theme tabler has changed. If you had the tabler config published you are good to go. **In case you don't have the tabler theme config published** and want to keep the old layout, you should publish it by running `php artisan vendor:publish --tag="theme-tabler-config"` and changing: ```diff - 'layout' => 'horizontal', + 'layout' => 'horizontal_overlap', @@ -156,10 +158,10 @@ If the table view still looks wonky (search bar out of place, big + instead of e ### Upgrade Add-ons -**backpack/file-manager** Using the File Manager package? Most of the views that weren't in use were removed, and the dependencies were bumped. If you didn't do any customization you should delete the `resources/views/vendor/elfinder` (`rm -rf resources/views/vendor/elfinder`) folder. +**backpack/file-manager** Using the File Manager package? Most of the views that weren't in use were removed, and the dependencies were bumped. If you didn't do any customization you should delete the `resources/views/vendor/elfinder` (`rm -rf resources/views/vendor/elfinder`) folder. No need to publish any views anymore if you are not customizing them. If you were, publish the new view files (`php artisan vendor:publish --provider="Backpack\FileManager\FileManagerServiceProvider" --tag="elfinder-views"`). Then apply your customization on the new files, now located at: `resources/views/vendor/backpack/filemanager/` -Additional the `browse` and `browse_multiple` **fields/columns** are now part of this package. If you previously made any modifications to this fields/columns you should publish the new views (`php artisan vendor:publish --provider="Backpack\FileManager\FileManagerServiceProvider" --tag="filemanger-fields"` and `php artisan vendor:publish --provider="Backpack\FileManager\FileManagerServiceProvider" --tag="filemanager-columns"`), and carry over the modifications from the old files to this new files. +Additional the `browse` and `browse_multiple` **fields/columns** are now part of this package. If you previously made any modifications to this fields/columns you should publish the new views (`php artisan vendor:publish --provider="Backpack\FileManager\FileManagerServiceProvider" --tag="filemanger-fields"` and `php artisan vendor:publish --provider="Backpack\FileManager\FileManagerServiceProvider" --tag="filemanager-columns"`), and carry over the modifications from the old files to this new files. --- From 2a6b65e4e3f5107a83d5913f52620cfcb713a30c Mon Sep 17 00:00:00 2001 From: Pedro Martins Date: Tue, 19 Aug 2025 18:43:56 +0100 Subject: [PATCH 24/32] update json column docs docs for https://github.com/Laravel-Backpack/CRUD/pull/5845 --- 7.x-dev/crud-columns.md | 1 + 1 file changed, 1 insertion(+) diff --git a/7.x-dev/crud-columns.md b/7.x-dev/crud-columns.md index 93986ef..a06774b 100644 --- a/7.x-dev/crud-columns.md +++ b/7.x-dev/crud-columns.md @@ -446,6 +446,7 @@ Display database stored JSON in a prettier way to your users. 'label' => 'JSON', 'type' => 'json', // 'escaped' => false, // echo using {!! !!} instead of {{ }}, in order to render HTML + 'toggle' => true //show a toggle button on the column that show/hide the json contents ], ``` From ddb7f4f77f06ca1f6b0473bc0c6078e379f5c361 Mon Sep 17 00:00:00 2001 From: pxpm Date: Fri, 10 Oct 2025 16:37:35 +0100 Subject: [PATCH 25/32] add modal form docs --- 7.x-dev/base-components.md | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/7.x-dev/base-components.md b/7.x-dev/base-components.md index 139b2d7..ac02028 100644 --- a/7.x-dev/base-components.md +++ b/7.x-dev/base-components.md @@ -90,7 +90,7 @@ These are the components that Backpack uses inside the default CRUD operations. ![Backpack v7 Dataform component](https://backpackforlaravel.com/uploads/v7/dataform_component.jpg) -This component helps you show a form _anywhere you want_, so the admin to easily create or edit an entries for an Eloquent model. The dataform component is a extension of a CrudController - so a CrudController for that entity needs to be already set up, and passed to this component as a parameter: +This component helps you show a form _anywhere you want_, so the admin can easily create or edit an entries for an Eloquent model. The dataform component is a extension of a CrudController - so a CrudController for that entity needs to be already set up, and passed to this component as a parameter: ```html @@ -118,6 +118,38 @@ This component helps you show a form _anywhere you want_, so the admin to easily
+ +### Dataform Modal + +![Backpack v7 Dataform Modal component](https://backpackforlaravel.com/uploads/v7/dataform_component.jpg) + +This component helps you show a form _anywhere you want_ inside a modal, so the admin can easily create or edit an entry for an Eloquent model without having to refresh the whole page. The dataform modal component is a extension of a CrudController - so a CrudController for that entity needs to be already set up, and passed to this component as a parameter: + +```html + +``` + +**Configuration options:** +- `name='invoice_form'` - by default, a name will be generated; but you can pick one you can recognize; +- `operation='create'` - by default, the datatable component will pick up everything that controller sets up for the Create operation; if you want to change the operation it will initialize, you can pass this parameter; +- `:entry="\App\Models\Invoice::find(1)"` - if you want to use UpdateOperation or a custom form operation that needs the entry; +- `:setup="function($crud, $parent) {}"` - if you want to make changes to the operation setup (eg. add/remove fields, configure functionality), you can use this parameter; the closure passed here will be run _after_ the setup of that operation had already completed; + +**Advanced example:** + +```html + +``` +
+ ### Datatable From a9f03c199982e093f717dc73daf438ff4909242f Mon Sep 17 00:00:00 2001 From: pxpm Date: Fri, 10 Oct 2025 17:42:45 +0100 Subject: [PATCH 26/32] wip --- 7.x-dev/base-components.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/7.x-dev/base-components.md b/7.x-dev/base-components.md index ac02028..fa9f63a 100644 --- a/7.x-dev/base-components.md +++ b/7.x-dev/base-components.md @@ -150,6 +150,8 @@ This component helps you show a form _anywhere you want_ inside a modal, so the ```
+> **NOTE**: The tinymce and date_picker (jquery version) does not properly work in this context. Please use any alternative. + ### Datatable From f0b0d184cf37f587ac12253a957d858e33faba6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20T=C4=83b=C4=83citu?= Date: Mon, 20 Oct 2025 15:24:57 +0300 Subject: [PATCH 27/32] Update composer.json requirement for backpack/crud --- 7.x-dev/upgrade-guide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/7.x-dev/upgrade-guide.md b/7.x-dev/upgrade-guide.md index 3317f72..26f1a73 100644 --- a/7.x-dev/upgrade-guide.md +++ b/7.x-dev/upgrade-guide.md @@ -36,13 +36,13 @@ Please make sure your project respects the requirements below, before you start Step 1. Update your ```composer.json``` file to require: ``` - "backpack/crud": "^7.0@dev", + "backpack/crud": "^7.0.0-beta", ``` Step 2. Bump the version of any first-party Backpack add-ons you have installed (eg. `backpack/pro`, `backpack/editable-columns` etc.) to the versions that support Backpack v6. For 3rd-party add-ons, please check each add-on's Github page. Here's a quick list of 1st party packages and versions: ```js - "backpack/crud": "^7.0@dev", + "backpack/crud": "^7.0.0-beta", "backpack/pro": "^3.0@dev", "backpack/filemanager": "dev-next", "backpack/theme-coreuiv2": "dev-next", From a7dce0ddb35b1fbc2f575e4f69fa55d68b171017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20T=C4=83b=C4=83citu?= Date: Thu, 23 Oct 2025 08:57:03 +0300 Subject: [PATCH 28/32] Update Backpack add-ons and configuration options Updated version requirements for Backpack add-ons and added new configuration options for operations. --- 7.x-dev/upgrade-guide.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/7.x-dev/upgrade-guide.md b/7.x-dev/upgrade-guide.md index 26f1a73..d09616e 100644 --- a/7.x-dev/upgrade-guide.md +++ b/7.x-dev/upgrade-guide.md @@ -43,7 +43,7 @@ Please make sure your project respects the requirements below, before you start ```js "backpack/crud": "^7.0.0-beta", - "backpack/pro": "^3.0@dev", + "backpack/pro": "^3.0.0-alpha", "backpack/filemanager": "dev-next", "backpack/theme-coreuiv2": "dev-next", "backpack/theme-coreuiv4": "dev-next", @@ -94,7 +94,16 @@ No changes needed. ### Config -**Theme Tabler** - The default layout for theme tabler has changed. If you had the tabler config published you are good to go. **In case you don't have the tabler theme config published** and want to keep the old layout, you should publish it by running `php artisan vendor:publish --tag="theme-tabler-config"` and changing: +Step X. **Operation Config Files** - We have added new configuration options in the files inside `config/backpack/operations/`. If you have those files published, it is recommended that you copy the new options in your files too. + +Step X. **Show Operation New Default** - inside `config/backpack/operations/show.php` you'll find a new option, to choose which component will be used on the show operation. By default it's the new component `bp-datagrid`, but you can switch to `bp-datalist` if you want to keep the same look as before: + +```php + // Which component to use for displaying the Show page? + 'component' => 'bp-datalist', // options: bp-datagrid, bp-datalist, or a custom component alias +``` + +Step X. **Theme Tabler** - The default layout for theme tabler has changed. If you had the tabler config published you are good to go. **In case you don't have the tabler theme config published** and want to keep the old layout, you should publish it by running `php artisan vendor:publish --tag="theme-tabler-config"` and changing: ```diff - 'layout' => 'horizontal', + 'layout' => 'horizontal_overlap', From bac899e88a7b2dab1fd2893db3cf9829e4d550c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20T=C4=83b=C4=83citu?= Date: Thu, 23 Oct 2025 10:30:08 +0300 Subject: [PATCH 29/32] Add RTL text direction configuration instructions Added instructions for setting text direction to RTL in UI configuration. --- 7.x-dev/base-how-to.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/7.x-dev/base-how-to.md b/7.x-dev/base-how-to.md index 3e13613..8d2a90a 100644 --- a/7.x-dev/base-how-to.md +++ b/7.x-dev/base-how-to.md @@ -6,6 +6,17 @@ ## Look and feel + +### Text direction: LTR or RTL + +By default, the text direction is set to left-to-right. If your UI is in Arabic, Hebrew or any other language that needs to show right-to-left, you can easily enable that - just go to `config/backpack/ui.php` and change the `html_direction` variable to `rtl`: + +``` + // Direction, according to language + // (left-to-right vs right-to-left) + 'html_direction' => 'ltr', +``` + ### Customize the menu or sidebar From 63f4ecccfe9826b7e3aa9a65642c766da6bb1023 Mon Sep 17 00:00:00 2001 From: pxpm Date: Tue, 28 Oct 2025 16:52:00 +0000 Subject: [PATCH 30/32] wip --- 7.x-dev/base-components.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/7.x-dev/base-components.md b/7.x-dev/base-components.md index fa9f63a..231f796 100644 --- a/7.x-dev/base-components.md +++ b/7.x-dev/base-components.md @@ -97,7 +97,6 @@ This component helps you show a form _anywhere you want_, so the admin can easil ``` **Configuration options:** -- `name='invoice_form'` - by default, a name will be generated; but you can pick one you can recognize; - `operation='create'` - by default, the datatable component will pick up everything that controller sets up for the Create operation; if you want to change the operation it will initialize, you can pass this parameter; - `:entry="\App\Models\Invoice::find(1)"` - if you want to use UpdateOperation or a custom form operation that needs the entry; - `:setup="function($crud, $parent) {}"` - if you want to make changes to the operation setup (eg. add/remove fields, configure functionality), you can use this parameter; the closure passed here will be run _after_ the setup of that operation had already completed; @@ -123,16 +122,17 @@ This component helps you show a form _anywhere you want_, so the admin can easil ![Backpack v7 Dataform Modal component](https://backpackforlaravel.com/uploads/v7/dataform_component.jpg) -This component helps you show a form _anywhere you want_ inside a modal, so the admin can easily create or edit an entry for an Eloquent model without having to refresh the whole page. The dataform modal component is a extension of a CrudController - so a CrudController for that entity needs to be already set up, and passed to this component as a parameter: +This component helps you show a form _anywhere you want_ inside a modal, so the admin can easily create or edit an entry for an Eloquent model without having to refresh the whole page. + +To use this component you are required to add `CreateInModalOperation` and/or `UpdateInModalOperation` in your CrudController. The dataform modal component is a extension of a CrudController - so a CrudController for that entity needs to be already set up, and passed to this component as a parameter: ```html ``` **Configuration options:** -- `name='invoice_form'` - by default, a name will be generated; but you can pick one you can recognize; -- `operation='create'` - by default, the datatable component will pick up everything that controller sets up for the Create operation; if you want to change the operation it will initialize, you can pass this parameter; -- `:entry="\App\Models\Invoice::find(1)"` - if you want to use UpdateOperation or a custom form operation that needs the entry; +- `operation='createInModal'` - by default, the component will pick up everything that controller sets up for the Create operation; if you want to change the operation it will initialize, you can pass this parameter, eg: `updateInModal` +- `:entry="\App\Models\Invoice::find(1)"` - if you want to use UpdateInModalOperation or a custom form operation that needs the entry; - `:setup="function($crud, $parent) {}"` - if you want to make changes to the operation setup (eg. add/remove fields, configure functionality), you can use this parameter; the closure passed here will be run _after_ the setup of that operation had already completed; **Advanced example:** @@ -141,7 +141,7 @@ This component helps you show a form _anywhere you want_ inside a modal, so the ### Datatable From 7a7cd52b62c65ec84cddf886fba600fb1c4e8be5 Mon Sep 17 00:00:00 2001 From: pxpm Date: Tue, 28 Oct 2025 16:56:23 +0000 Subject: [PATCH 31/32] wip --- 7.x-dev/base-components.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/7.x-dev/base-components.md b/7.x-dev/base-components.md index 231f796..ef7e21e 100644 --- a/7.x-dev/base-components.md +++ b/7.x-dev/base-components.md @@ -126,6 +126,12 @@ This component helps you show a form _anywhere you want_ inside a modal, so the To use this component you are required to add `CreateInModalOperation` and/or `UpdateInModalOperation` in your CrudController. The dataform modal component is a extension of a CrudController - so a CrudController for that entity needs to be already set up, and passed to this component as a parameter: +First, in your CrudController, either remove `CreateOperation` in favor of `CreateInModalOperation`, or you can keep both operations. Having both of them is usefull if you want your ListOperation to still show the regular "Create" button, but you would like also to have the possibility to create this entity somewhere else in your application using a modal form. + +```php +use \Backpack\DataformModal\Http\Controllers\Operations\CreateInModalOperation; +``` + ```html ``` From 9e2f8a2a9cd4acc742dff7249a955fc137ffbc26 Mon Sep 17 00:00:00 2001 From: Pedro Martins Date: Fri, 7 Nov 2025 10:44:37 +0000 Subject: [PATCH 32/32] add save action docs (#640) * add save action docs --- 7.x-dev/base-components.md | 31 +++++++++++++ 7.x-dev/crud-save-actions.md | 85 ++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) diff --git a/7.x-dev/base-components.md b/7.x-dev/base-components.md index ef7e21e..dd5da5a 100644 --- a/7.x-dev/base-components.md +++ b/7.x-dev/base-components.md @@ -100,6 +100,8 @@ This component helps you show a form _anywhere you want_, so the admin can easil - `operation='create'` - by default, the datatable component will pick up everything that controller sets up for the Create operation; if you want to change the operation it will initialize, you can pass this parameter; - `:entry="\App\Models\Invoice::find(1)"` - if you want to use UpdateOperation or a custom form operation that needs the entry; - `:setup="function($crud, $parent) {}"` - if you want to make changes to the operation setup (eg. add/remove fields, configure functionality), you can use this parameter; the closure passed here will be run _after_ the setup of that operation had already completed; +- `:save-actions="[]"` - provide an array of save action definitions or save action classes to replace the defaults (see [Custom save actions](#dataform-custom-save-actions)); +- `:form-inside-card="true"` - render the form inside a Backpack card wrapper so it visually matches the default create/update screens; leave it `false` to output only the raw form markup. **Advanced example:** @@ -115,6 +117,33 @@ This component helps you show a form _anywhere you want_, so the admin can easil /> ``` + +#### Custom save actions + +The Dataform component can swap out the default `Save and back / edit / new` buttons with your own logic. Pass an array to the `:save-actions` attribute containing save action classes (or definitions) that implement Backpack's `SaveActionInterface`: + +```php +@php + use App\Backpack\Crud\SaveActions\SaveAndApprove; + use Backpack\CRUD\app\Library\CrudPanel\SaveActions\SaveAndBack; +@endphp + + +``` + +Each entry in the array can be: +- an instance of a class that implements `SaveActionInterface` (recommended); +- the fully qualified class name of a save action (the container will resolve it); +- a plain array definition (see [`crud-save-actions.md`](crud-save-actions.md)). + +Backpack will replace the default actions for that form, honour the order defined by each class, and fallback to the first action if no default applies. +
@@ -140,6 +169,7 @@ use \Backpack\DataformModal\Http\Controllers\Operations\CreateInModalOperation; - `operation='createInModal'` - by default, the component will pick up everything that controller sets up for the Create operation; if you want to change the operation it will initialize, you can pass this parameter, eg: `updateInModal` - `:entry="\App\Models\Invoice::find(1)"` - if you want to use UpdateInModalOperation or a custom form operation that needs the entry; - `:setup="function($crud, $parent) {}"` - if you want to make changes to the operation setup (eg. add/remove fields, configure functionality), you can use this parameter; the closure passed here will be run _after_ the setup of that operation had already completed; +- `:save-actions="[]"` - replace the default modal buttons with your own save action classes. **Advanced example:** @@ -172,6 +202,7 @@ Useful if you want to show the entries in the database, for an Eloquent model. T **Configuration options:** - `name='invoices_datatable'` - by default, a name will be generated; but you can pick one you can recognize; - `operation='list'` - by default, the datatable component will pick up everything that controller sets up for the List operation; if you want to change the operation it will initialize, you can pass this parameter; +- `:useFixedHeader="false"` - set this to explicitly enable or disable the sticky header; it defaults to the operation's `useFixedHeader` setting, falling back to `true`; - `:setup="function($crud, $parent) {}"` - if you want to make changes to the operation setup (eg. add/remove columns, configure functionality), you can use this parameter; the closure passed here will be run _after_ the setup of that operation had already completed; **Advanced example:** diff --git a/7.x-dev/crud-save-actions.md b/7.x-dev/crud-save-actions.md index 4fb61c8..679aac2 100644 --- a/7.x-dev/crud-save-actions.md +++ b/7.x-dev/crud-save-actions.md @@ -16,6 +16,91 @@ There are four save actions registered by Backpack by default. They are: - ```save_and_new``` (Save and go to create new entity page) - ```save_and_preview``` (Save and go to show the current entity) + +## Save Action Classes + +Save actions are now first-class citizens. Instead of maintaining large array definitions in each CrudController, you can encapsulate the behaviour inside PHP classes that implement `Backpack\CRUD\app\Library\CrudPanel\SaveActions\SaveActionInterface`. Backpack ships with `SaveAndBack`, `SaveAndEdit`, `SaveAndNew`, and `SaveAndPreview` as examples, and also provides `SaveAndList` for projects that want an explicit "Save and go to list" button. + +### Quick start + +1. **Create a class** inside your application (for example `app/Backpack/Crud/SaveActions/SaveAndApprove.php`). +2. **Extend** `AbstractSaveAction` (recommended) or implement `SaveActionInterface` directly. +3. **Override** the methods that describe your button. +4. **Register** the class with `CRUD::addSaveAction()` / `CRUD::replaceSaveActions()` or pass it to Blade components like ``. + +```php +hasAccess('update') && $crud->entry?->canBeApproved(); + } + + public function getRedirectUrl(CrudPanel $crud, Request $request, $itemId = null): ?string + { + return route('admin.invoices.approve', $itemId ?? $request->input('id')); + } +} +``` + +> **Tip:** `AbstractSaveAction` already implements `toArray()`, order handling, and sensible defaults. Override only what you need. If you must store additional data, you can still return a custom array by implementing `SaveActionInterface` yourself. + +### Registering class-based actions + +Inside your CrudController you can now pass the class instead of an array: + +```php +use App\Backpack\Crud\SaveActions\SaveAndApprove; + +CRUD::replaceSaveActions([ + new SaveAndApprove(), + \Backpack\CRUD\app\Library\CrudPanel\SaveActions\SaveAndBack::class, +]); +``` + +Backpack recognizes three inputs when registering save actions: +- an instantiated save action class; +- the fully qualified class name (it is resolved via the container so dependencies can be injected); +- the legacy associative array definition (still supported). + +The action `order` is taken from the class (or array) and Backpack reorders conflicts automatically. If you need to adjust the order later you can still call `CRUD::orderSaveActions()`. + +### Using classes in Blade components + +The `bp-dataform` component accept save action classes through the `:save-actions` attribute. This allows you to reuse the same custom buttons outside CrudControllers: + +```php + +``` + +When no save actions are provided, Backpack falls back to the defaults registered on the controller. + ## Save Actions API