AnnouncementController.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Announcement;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class AnnouncementController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new Announcement(), function (Grid $grid) {
  18. $grid->column('garden_name');
  19. $grid->column('content');
  20. $grid->column('created_at');
  21. $grid->disableEditButton();
  22. $grid->disableCreateButton();
  23. $grid->filter(function (Grid\Filter $filter) {
  24. $filter->panel();
  25. $filter->date('created_at')->datetime()->width(4);
  26. });
  27. });
  28. }
  29. /**
  30. * Make a show builder.
  31. *
  32. * @param mixed $id
  33. *
  34. * @return Show
  35. */
  36. protected function detail($id)
  37. {
  38. return Show::make($id, new Announcement(), function (Show $show) {
  39. //$show->field('garden_name');
  40. $show->field('title');
  41. $show->field('content');
  42. $show->field('created_at');
  43. });
  44. }
  45. /**
  46. * Make a form builder.
  47. *
  48. * @return Form
  49. */
  50. protected function form()
  51. {
  52. return Form::make(new Announcement(), function (Form $form) {
  53. $form->text('garden_name');
  54. $form->text('content');
  55. });
  56. }
  57. }