justinmoh / backpack-helper
A helper package for Laravel-Backpack CRUD that allows using CRUD components as chained method.
Installs: 67
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 4
pkg:composer/justinmoh/backpack-helper
Requires
- php: ^7.2.5|^8.0
- backpack/crud: 4.1.*
- illuminate/support: ^7.0|^8.0
Requires (Dev)
- mockery/mockery: ^1.1
- phpunit/phpunit: ~8.0|~9.0
- sempro/phpunit-pretty-print: ^1.0
- 1.3.0
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- dev-master / 1.0.x-dev
- 1.0.0
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.3
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.0
- 0.5.1
- 0.5.0
- 0.4.1
- 0.4.0
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.1
- 0.2.0
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-dependabot/composer/symfony/http-kernel-5.4.20
- dev-dependabot/composer/guzzlehttp/guzzle-7.4.5
- dev-dependabot/composer/guzzlehttp/psr7-2.2.1
- dev-dependabot/composer/doctrine/dbal-3.1.4
This package is auto-updated.
Last update: 2025-09-29 02:42:52 UTC
README
This package intends to provide a friendlier interface while using Backpack CRUD,
by makes use of laravel's facade.
According to the way Backpack\Crud works, this package rely the trailing
method to perform the magic. Currently these compulsory trailing methods are:
public function toField($extraConfigToBeMerged = []): CrudPanelpublic function toColumn($extraConfigToBeMerged = []): CrudPanelpublic function toFilter($extraConfigToBeMerged = []): void
All other methods return the current instance $this. In order to perform
method chain, refer class source code for api, example:
CrudColumn::init(string $label, ?string $name = null, $priority = null): self CrudField::init(string $label, ?string $name = null, $width = null): self
There is a 2-steps plan:
- To include all
Backpack CRUDcolumns, fields, and filters - To merge the helper classes into one.
These is no test written, yet.
Installation
Via Composer
$ composer require justinmoh/backpack-helper:~0.2
Usage
use \JustinMoh\BackpackHelper\CrudHelper; use \JustinMoh\BackpackHelper\Facades\Columns\DatetimeColumn; use \JustinMoh\BackpackHelper\Facades\Columns\SelectColumn; use \JustinMoh\BackpackHelper\Facades\Columns\TextColumn; use \JustinMoh\BackpackHelper\Facades\Fields\RadioField; use \JustinMoh\BackpackHelper\Facades\Fields\Select2FromArrayField; use \JustinMoh\BackpackHelper\Facades\Fields\UploadMultipleField; use \JustinMoh\BackpackHelper\Facades\Filters\Select2MultipleFilter; use \JustinMoh\BackpackHelper\Facades\Filters\SimpleFilter; // ... protected function setupListOperation() { // a datetime column with priority `1` DatetimeColumn::init('Date & Time Check In', 'datetime_check_in', 1) ->toColumn(); // you can also separate the method chains. DatetimeColumn::label('Date & Time Check Out')->name('datetime_check_out') ->toColumn(); // auto guessing `name` with `label` TextColumn::label('Name')->toColumn(); // backpack's `select` column type SelectColumn::init('Category', 'category_id') ->entity('category')->attribute('display_name')->model(\App\Category::class) ->toColumn(); } // ... protected function setupCreateOperation() { // a field with wrapperAttribute col-md-6 (or col-lg-6 ?) UploadMultipleField::init('Attach Documents', 'customer_documents', 6) ->toField(); // an inline yes no radio button, disabled RadioField::init('Is Vip')->width(3)->inline() ->options(CrudHelper::YES_NO_OPTIONS) ->disabled()->toField(); // select 2 Select2FromArrayField::init('Room Type', 'room_type_id', 4)->required() ->options(\App\RoomType::all()->prepend('')->pluck('name','id')->toArray()) ->toField(); } // ... protected function setupListOperation() { SimpleFilter::init('Only New', 'status_new') ->query(function() { \CRUD::addClause('onlyNew'); })->toFilter(); Select2MultipleFilter::label('Select Room Type(s)') ->options( function () { return \App\RoomType::all()->pluck('name', 'id')->toArray(); } )->query( function ($value) { \CRUD::addClause('whereInRoomTypes', json_decode($values)); } )->toFilter(); }
Change log
Please see the changelog for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email author email instead of using the issue tracker.
Credits
License
license. Please see the license file for more information.