TakebackEntrustmentController.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\TakebackEntrustment;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class TakebackEntrustmentController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new TakebackEntrustment(), function (Grid $grid) {
  18. $grid->column('student_id')->using(config('map.students'));
  19. $grid->column('entrust_time');
  20. $grid->column('take_back_person')->using(config('map.parent_ids'));
  21. $grid->column('take_back_desc');
  22. $grid->column('take_back_photos');
  23. $grid->column('sign');
  24. $grid->filter(function (Grid\Filter $filter) {
  25. $filter->panel();
  26. $filter->date('created_at')->datetime()->width(4);
  27. $filter->equal('student_id','输入/选择学生')->select(config('map.students'))->width(4);
  28. });
  29. });
  30. }
  31. /**
  32. * Make a show builder.
  33. *
  34. * @param mixed $id
  35. *
  36. * @return Show
  37. */
  38. protected function detail($id)
  39. {
  40. return Show::make($id, new TakebackEntrustment(), function (Show $show) {
  41. $show->row(function (Show\Row $show) {
  42. $show->field('content','接回委托详情')
  43. ->width(8)
  44. ->unescape()
  45. ->as(function () {
  46. $html = '';
  47. $html .= '<div style="text-align:left">';
  48. $html .= '<div style="margin-top:5px">接回对象:' . config('map.students')[$this->student_id] . '</div>';
  49. $html .= '<div style="margin-top:5px">接回家长:' . config('map.parent_ids')[$this->take_back_person] . '</div>';
  50. $html .= '<div style="margin-top:5px">接回时间:' . $this->entrust_time . '</div>';
  51. $html .= '<div style="margin-top:5px">接回说明:' . $this->take_back_desc . '</div>';
  52. $html .= '<div style="margin-top:5px">接回照片:</div>';
  53. $html .= '<img data-action="preview-img" src="' . $this->photos . '" style="height:50px;width:50px;cursor:pointer;margin-right:10px;" class="img img-thumbnail">';
  54. $html .= '<div style="margin-top:5px">签名:' . $this->sign . '</div>';
  55. $html .= '</div>';
  56. return $html;
  57. });
  58. });
  59. });
  60. }
  61. /**
  62. * Make a form builder.
  63. *
  64. * @return Form
  65. */
  66. protected function form()
  67. {
  68. return Form::make(new TakebackEntrustment(), function (Form $form) {
  69. $form->text('student_id');
  70. $form->text('entrust_time');
  71. $form->text('take_back_person');
  72. $form->text('take_back_desc');
  73. $form->text('take_back_photos');
  74. $form->text('sign');
  75. });
  76. }
  77. }