DiaryMoodLevelController.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\DiaryMoodLevel;
  4. use Encore\Admin\Controllers\AdminController;
  5. use Encore\Admin\Form;
  6. use Encore\Admin\Grid;
  7. use Encore\Admin\Show;
  8. class DiaryMoodLevelController 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 DiaryMoodLevel());
  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(DiaryMoodLevel::findOrFail($id));
  41. $show->field('id', __('Id'));
  42. $show->field('name', __('Name'));
  43. $show->field('pic', __('Pic'));
  44. $show->field('color', __('Color'));
  45. $show->field('rank', __('Rank'));
  46. $show->field('created_at', __('Created at'));
  47. $show->field('updated_at', __('Updated at'));
  48. $show->field('deleted_at', __('Deleted at'));
  49. return $show;
  50. }
  51. /**
  52. * Make a form builder.
  53. *
  54. * @return Form
  55. */
  56. protected function form()
  57. {
  58. $form = new Form(new DiaryMoodLevel());
  59. $form->text('name', __('级别名'));
  60. $form->image('pic', __('图片'));
  61. $form->color('color', __('颜色'));
  62. $form->number('rank', __('排序 越大越靠前'));
  63. return $form;
  64. }
  65. }