DiaryMoodTagController.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\DiaryMoodTag;
  4. use Encore\Admin\Controllers\AdminController;
  5. use Encore\Admin\Form;
  6. use Encore\Admin\Grid;
  7. use Encore\Admin\Show;
  8. class DiaryMoodTagController extends AdminController
  9. {
  10. /**
  11. * Title for current resource.
  12. *
  13. * @var string
  14. */
  15. protected $title = '心情标签';
  16. /**
  17. * Make a grid builder.
  18. *
  19. * @return Grid
  20. */
  21. protected function grid()
  22. {
  23. $grid = new Grid(new DiaryMoodTag());
  24. $grid->column('id', __('Id'));
  25. $grid->column('name', __('标签名'));
  26. $grid->column('color', __('颜色'));
  27. $grid->column('rank', __('排序 越大越靠前'));
  28. $grid->column('created_at', __('创建时间'));
  29. $grid->column('updated_at', __('更新时间'));
  30. return $grid;
  31. }
  32. /**
  33. * Make a show builder.
  34. *
  35. * @param mixed $id
  36. * @return Show
  37. */
  38. protected function detail($id)
  39. {
  40. $show = new Show(DiaryMoodTag::findOrFail($id));
  41. $show->field('id', __('Id'));
  42. $show->field('name', __('Name'));
  43. $show->field('color', __('Color'));
  44. $show->field('rank', __('Rank'));
  45. $show->field('created_at', __('Created at'));
  46. $show->field('updated_at', __('Updated at'));
  47. $show->field('deleted_at', __('Deleted at'));
  48. return $show;
  49. }
  50. /**
  51. * Make a form builder.
  52. *
  53. * @return Form
  54. */
  55. protected function form()
  56. {
  57. $form = new Form(new DiaryMoodTag());
  58. $form->text('name', __('标签名'));
  59. $form->color('color', __('颜色'));
  60. $form->number('rank', __('排序 越大越靠前'));
  61. return $form;
  62. }
  63. }