EmailLogController.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace App\Admin\Controllers\System;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\EmailLog;
  5. use Encore\Admin\Controllers\HasResourceActions;
  6. use Encore\Admin\Form;
  7. use Encore\Admin\Grid;
  8. use Encore\Admin\Layout\Content;
  9. class EmailLogController extends Controller
  10. {
  11. use HasResourceActions;
  12. /**
  13. * Index interface.
  14. *
  15. * @param Content $content
  16. * @return Content
  17. */
  18. public function index(Content $content)
  19. {
  20. return $content
  21. ->header('邮件日志')
  22. ->description('')
  23. ->body($this->grid());
  24. }
  25. /**
  26. * Show interface.
  27. *
  28. * @param mixed $id
  29. * @param Content $content
  30. * @return Content
  31. */
  32. public function show($id, Content $content)
  33. {
  34. return $content
  35. ->header('邮件日志')
  36. ->description('详细')
  37. ->body($this->detail($id));
  38. }
  39. /**
  40. * Make a grid builder.
  41. *
  42. * @return Grid
  43. */
  44. protected function grid()
  45. {
  46. $grid = new Grid(new EmailLog);
  47. $grid->model()->orderBy('id', 'desc');
  48. $grid->id('ID');
  49. $grid->send_from('发送账号');
  50. $grid->send_to('发送地址');
  51. $grid->subject('邮件主题');
  52. $grid->status('状态')->display(function ($status) {
  53. if ($status == 1) {
  54. return '成功';
  55. } elseif ($status==2) {
  56. return '失败';
  57. } else {
  58. return '待发送';
  59. }
  60. });
  61. $grid->created_at('添加时间');
  62. $grid->updated_at('更新时间');
  63. $grid->disableActions();
  64. return $grid;
  65. }
  66. /**
  67. * Make a form builder.
  68. *
  69. * @return Form
  70. */
  71. protected function form()
  72. {
  73. $form = new Form(new EmailLog);
  74. $form->display('ID');
  75. $form->display('Created at');
  76. $form->display('Updated at');
  77. return $form;
  78. }
  79. }