Grid
CREATE TABLE `movies` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`director` int(10) unsigned NOT NULL,
`describe` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`rate` tinyint unsigned NOT NULL,
`released` enum(0, 1),
`release_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;use App\Models\Movie;
use Ezadev\Admin\Grid;
use Ezadev\Admin\Facades\Admin;
use App\Models\Movie;
use Ezadev\Admin\Grid;
use Ezadev\Admin\Facades\Admin;
$grid = new Grid(new Movie);
// The first column displays the id field and sets the column as a sortable column
$grid->id('ID')->sortable();
// The second column shows the title field, because the title field name and the Grid object's title method conflict, so use Grid's column () method instead
$grid->column('title');
// The third column shows the director field, which is set by the display($callback) method to display the corresponding user name in the users table
$grid->director()->display(function($userId) {
return User::find($userId)->name;
});
// The fourth column appears as the describe field
$grid->describe();
// The fifth column is displayed as the rate field
$grid->rate();
// The sixth column shows the released field, formatting the display output through the display($callback) method
$grid->released('Release?')->display(function ($released) {
return $released ? 'yes' : 'no';
});
// The following shows the columns for the three time fields
$grid->release_at();
$grid->created_at();
$grid->updated_at();
// The filter($callback) method is used to set up a simple search box for the table
$grid->filter(function ($filter) {
// Sets the range query for the created_at field
$filter->between('created_at', 'Created Time')->datetime();
});Basic Usage
Add a column
Modify the source data
Sets the number of lines displayed per page
Modify the display output of column
Disable the create button
Disable Pagination
Disable data filter
Disable the export button
Disable row selector
Disable row actions
Disable column selector
Set options for perPage selector
Relation
One to one
One to many
Many to many
Last updated