ExampleController.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use Encore\Admin\Controllers\AdminController;
  4. use Encore\Admin\Form;
  5. use Encore\Admin\Grid;
  6. use Encore\Admin\Show;
  7. class ExampleController extends AdminController
  8. {
  9. /**
  10. * Title for current resource.
  11. *
  12. * @var string
  13. */
  14. protected $title = 'Example controller';
  15. /**
  16. * Make a grid builder.
  17. *
  18. * @return Grid
  19. */
  20. protected function grid()
  21. {
  22. $grid = new Grid(new ExampleModel);
  23. $grid->column('id', __('ID'))->sortable();
  24. $grid->column('created_at', __('Created at'));
  25. $grid->column('updated_at', __('Updated at'));
  26. return $grid;
  27. }
  28. /**
  29. * Make a show builder.
  30. *
  31. * @param mixed $id
  32. * @return Show
  33. */
  34. protected function detail($id)
  35. {
  36. $show = new Show(ExampleModel::findOrFail($id));
  37. $show->field('id', __('ID'));
  38. $show->field('created_at', __('Created at'));
  39. $show->field('updated_at', __('Updated at'));
  40. return $show;
  41. }
  42. /**
  43. * Make a form builder.
  44. *
  45. * @return Form
  46. */
  47. protected function form()
  48. {
  49. $form = new Form(new ExampleModel);
  50. $form->display('id', __('ID'));
  51. $form->display('created_at', __('Created At'));
  52. $form->display('updated_at', __('Updated At'));
  53. return $form;
  54. }
  55. }