DiarySleepLevelController.php 1.9 KB

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