WxShopGuaranteeRecordController.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace App\Admin\Controllers\Shop;
  3. use App\Admin\Repositories\Shop\WxShopGuaranteeRecord;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class WxShopGuaranteeRecordController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new WxShopGuaranteeRecord(), function (Grid $grid) {
  18. $grid->model()->orderBy('id', 'desc');
  19. $grid->column('id')->sortable();
  20. $grid->column('shop_id');
  21. $grid->column('shop_id')->display(function ($v){
  22. return '<a href="'.admin_url('shops?id='.$v).'" target="_blank">'.$v.'</a>';
  23. });
  24. $grid->column('num');
  25. $grid->column('title');
  26. // $grid->column('created_at');
  27. $grid->column('updated_at')->sortable();
  28. $grid->filter(function (Grid\Filter $filter) {
  29. $filter->equal('id');
  30. $filter->equal('shop_id');
  31. });
  32. $grid->disableActions();
  33. $grid->disableBatchActions();
  34. $grid->disableCreateButton();
  35. });
  36. }
  37. /**
  38. * Make a show builder.
  39. *
  40. * @param mixed $id
  41. *
  42. * @return Show
  43. */
  44. protected function detail($id)
  45. {
  46. return Show::make($id, new WxShopGuaranteeRecord(), function (Show $show) {
  47. $show->field('id');
  48. $show->field('shop_id');
  49. $show->field('num');
  50. $show->field('title');
  51. $show->field('created_at');
  52. $show->field('updated_at');
  53. $show->disableEditButton();
  54. $show->disableDeleteButton();
  55. });
  56. }
  57. /**
  58. * Make a form builder.
  59. *
  60. * @return Form
  61. */
  62. protected function form()
  63. {
  64. return Form::make(new WxShopGuaranteeRecord(), function (Form $form) {
  65. $form->display('id');
  66. $form->text('shop_id');
  67. $form->text('num');
  68. $form->text('title');
  69. $form->display('created_at');
  70. $form->display('updated_at');
  71. $form->deleting(function (Form $form){
  72. global $__MINI_GLOBAL_TENANT_ID__;
  73. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  74. return $form->response()->error('权限不足,不可以删除其他分站对象');
  75. }
  76. });
  77. });
  78. }
  79. }