EpisodesCategoryController.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\EpisodesCategory;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class EpisodesCategoryController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new EpisodesCategory(), function (Grid $grid) {
  18. $grid->column('id')->sortable();
  19. $grid->column('name');
  20. $grid->column('created_at');
  21. });
  22. }
  23. /**
  24. * Make a show builder.
  25. *
  26. * @param mixed $id
  27. *
  28. * @return Show
  29. */
  30. protected function detail($id)
  31. {
  32. return Show::make($id, new EpisodesCategory(), function (Show $show) {
  33. $show->field('id');
  34. $show->field('name');
  35. $show->field('pid');
  36. $show->field('path');
  37. $show->field('sort');
  38. $show->field('created_at');
  39. $show->field('updated_at');
  40. });
  41. }
  42. /**
  43. * Make a form builder.
  44. *
  45. * @return Form
  46. */
  47. protected function form()
  48. {
  49. return Form::make(new EpisodesCategory(), function (Form $form) {
  50. $categoryModel = app(EpisodesCategory::class);
  51. $form->display('id');
  52. $form->text('name');
  53. $form->select('pid','')->options($categoryModel->selectOptions());
  54. $form->text('path');
  55. $form->display('created_at');
  56. $form->display('updated_at');
  57. });
  58. }
  59. }