SysConfigController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\SysConfig;
  4. use Encore\Admin\Controllers\AdminController;
  5. use Encore\Admin\Form;
  6. use Encore\Admin\Grid;
  7. use Encore\Admin\Show;
  8. class SysConfigController 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 SysConfig());
  24. $grid->column('id', __('Id'));
  25. $grid->column('name', __('系统名'));
  26. $grid->column('hotline_number', __('咨询电话'));
  27. $grid->column('hotline_number_pic', __('热线图片'))->lightbox([
  28. 'width' => 100
  29. ]);
  30. $grid->column('hot_search', __('热搜索关键词'));
  31. return $grid;
  32. }
  33. /**
  34. * Make a show builder.
  35. *
  36. * @param mixed $id
  37. * @return Show
  38. */
  39. protected function detail($id)
  40. {
  41. $show = new Show(SysConfig::findOrFail($id));
  42. $show->field('id', __('Id'));
  43. $show->field('name', __('系统名'));
  44. $show->field('hotline_number', __('咨询电话'));
  45. $show->field('hotline_number_pic', __('热线对应的图片'));
  46. $show->field('hot_search', __('热搜索关键词'));
  47. return $show;
  48. }
  49. /**
  50. * Make a form builder.
  51. *
  52. * @return Form
  53. */
  54. protected function form()
  55. {
  56. $form = new Form(new SysConfig());
  57. $form->text('name', __('系统名'));
  58. $form->text('hotline_number', __('咨询电话'));
  59. $form->image('hotline_number_pic', __('热线图片'))->uniqueName()->move('pics/'.date('Y').'/'.date('m'))->rules('required');
  60. $form->text('hot_search', __('热搜索关键词'));
  61. return $form;
  62. }
  63. }