链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.6 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\LanzuServiceHorseman;
  4. use App\Models\ImsCjdcMarket;
  5. use Dcat\Admin\Form;
  6. use Dcat\Admin\Grid;
  7. use Dcat\Admin\Show;
  8. use Dcat\Admin\Controllers\AdminController;
  9. class LanzuServiceHorsemanController extends AdminController
  10. {
  11. /**
  12. * Make a grid builder.
  13. *
  14. * @return Grid
  15. */
  16. protected function grid()
  17. {
  18. return Grid::make(new LanzuServiceHorseman(), function (Grid $grid) {
  19. $grid->id->sortable();
  20. $grid->name;
  21. $grid->tel;
  22. $grid->market_id('所属市场')->display(function (){
  23. return ImsCjdcMarket::find($this->market_id)->name;
  24. });
  25. $grid->status('状态')->using([1=>'正常',-1=>'禁用']);
  26. $grid->head_url->image('',50,50);
  27. $grid->created_at->display(function ($time){
  28. return date('Y-m-d H:i',$time);
  29. });
  30. $grid->filter(function (Grid\Filter $filter) {
  31. $filter->equal('id');
  32. });
  33. });
  34. }
  35. /**
  36. * Make a show builder.
  37. *
  38. * @param mixed $id
  39. *
  40. * @return Show
  41. */
  42. protected function detail($id)
  43. {
  44. return Show::make($id, new LanzuServiceHorseman(), function (Show $show) {
  45. $show->id;
  46. $show->user_id('懒ID');
  47. $show->name;
  48. $show->tel;
  49. $show->market_id('所属市场')->as(function (){
  50. return ImsCjdcMarket::find($this->market_id)->name;
  51. });
  52. $show->status('状态')->using([1=>'正常',-1=>'禁用']);
  53. $show->head_url->image();
  54. $show->created_at->as(function ($time){
  55. return date('Y-m-d H:i',$time);
  56. });
  57. $show->updated_at->as(function ($time){
  58. return date('Y-m-d H:i',$time);
  59. });
  60. });
  61. }
  62. /**
  63. * Make a form builder.
  64. *
  65. * @return Form
  66. */
  67. protected function form()
  68. {
  69. return Form::make(new LanzuServiceHorseman(), function (Form $form) {
  70. $form->display('id');
  71. $form->text('user_id','懒ID')->required();
  72. $form->text('name')->required();
  73. $form->mobile('tel')->required();
  74. $form->select('market_id','所属市场')->options(ImsCjdcMarket::getMarket())->required();
  75. $form->radio('status','状态')->options([1=>'启用',-1=>'禁用'])->value(1)->required();
  76. $form->image('head_url')->uniqueName()->required();
  77. $form->display('created_at');
  78. $form->display('updated_at');
  79. });
  80. }
  81. }