123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace App\Admin\Controllers;
- use Encore\Admin\Form;
- use Encore\Admin\Grid;
- use Encore\Admin\Facades\Admin;
- use Encore\Admin\Layout\Content;
- use App\Http\Controllers\Controller;
- use Encore\Admin\Controllers\ModelForm;
- class ExampleController extends Controller
- {
- use ModelForm;
- /**
- * Index interface.
- *
- * @return Content
- */
- public function index()
- {
- return Admin::content(function (Content $content) {
- $content->header('header');
- $content->description('description');
- $content->body($this->grid());
- });
- }
- /**
- * Edit interface.
- *
- * @param $id
- * @return Content
- */
- public function edit($id)
- {
- return Admin::content(function (Content $content) use ($id) {
- $content->header('header');
- $content->description('description');
- $content->body($this->form()->edit($id));
- });
- }
- /**
- * Create interface.
- *
- * @return Content
- */
- public function create()
- {
- return Admin::content(function (Content $content) {
- $content->header('header');
- $content->description('description');
- $content->body($this->form());
- });
- }
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Admin::grid(YourModel::class, function (Grid $grid) {
- $grid->id('序号')->sortable();
- $grid->created_at();
- $grid->updated_at();
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Admin::form(YourModel::class, function (Form $form) {
- $form->display('id', '序号');
- $form->display('created_at', 'Created At');
- $form->display('updated_at', 'Updated At');
- });
- }
- }
|