| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 | 
							- <?php
 
- namespace App\Admin\Controllers\System;
 
- use App\Http\Controllers\Controller;
 
- use App\Models\SmsQueue;
 
- use Encore\Admin\Controllers\HasResourceActions;
 
- use Encore\Admin\Facades\Admin;
 
- use Encore\Admin\Form;
 
- use Encore\Admin\Grid;
 
- use Encore\Admin\Layout\Content;
 
- use Encore\Admin\Show;
 
- class SmsQueueController extends Controller
 
- {
 
-     use HasResourceActions;
 
-     
 
-     public function index(Content $content)
 
-     {
 
-         return $content
 
-             ->header('短信记录')
 
-             ->description('发送记录')
 
-             ->body($this->grid());
 
-     }
 
-     
 
-     public function show($id, Content $content)
 
-     {
 
-         return $content
 
-             ->header('短信记录')
 
-             ->description('详细')
 
-             ->body($this->detail($id));
 
-     }
 
-     
 
-     public function edit($id, Content $content)
 
-     {
 
-         return $content
 
-             ->header('短信记录')
 
-             ->description('编辑')
 
-             ->body($this->form()->edit($id));
 
-     }
 
-     
 
-     public function create(Content $content)
 
-     {
 
-         return $content
 
-             ->header('短信记录')
 
-             ->description('创建')
 
-             ->body($this->createForm());
 
-     }
 
-     
 
-     protected function grid()
 
-     {
 
-         $grid = new Grid(new SmsQueue);
 
-         $grid->model()->orderBy('created_at', 'desc');
 
-         $grid->id('ID');
 
-         $grid->column('batch.name', '批次')->width(150);
 
-         $grid->utype('发送者')->display(function ($utype) {
 
-             switch ($utype) {
 
-                 case 1:
 
-                     $utype = '<span class="label label-success">企业</span>';
 
-                     break;
 
-                 case 2:
 
-                     $utype = '<span class="label label-primary">个人</span>';
 
-                     break;
 
-                 default:
 
-                     $utype = '<span class="label label-default">系统</span>';
 
-                     break;
 
-             }
 
-             return $utype;
 
-         });
 
-         $grid->s_number('手机号')->width(150);
 
-         $grid->s_body('短信内容')->width(200);
 
-         $grid->s_status('状态')->display(function ($m_status) {
 
-             switch ($m_status) {
 
-                 case 1:
 
-                     $m_status = '<span class="label label-success">成功</span>';
 
-                     break;
 
-                 case 2:
 
-                     $m_status = '<span class="label label-warning">等待</span>';
 
-                     break;
 
-                 case 3:
 
-                     $m_status = '<span class="label label-default">失败</span>';
 
-                     break;
 
-                 default:
 
-                     $m_status = '<span class="label label-warning">等待</span>';
 
-                     break;
 
-             }
 
-             return $m_status;
 
-         });
 
-         $grid->error_message('错误信息')->width(200);
 
-         $grid->s_sendtime('发送时间');
 
-         $grid->created_at('添加时间')->sortable();
 
-         $grid->actions(function ($actions) use ($grid) {
 
-             if (Admin::user()->can('system_sms_queue_delete')) {
 
-                 $actions->disableDelete(false);
 
-             }
 
-         });
 
-         if (Admin::user()->can('system_sms_queue_delete')) {
 
-             $grid->tools(function ($tools) {
 
-                 $tools->batch(function ($batch) {
 
-                     $batch->disableDelete(false);
 
-                 });
 
-             });
 
-             $grid->disableRowSelector(false);
 
-         }
 
-         $grid->filter(function ($filter) {
 
-             $filter->equal('s_status', '状态')->select([
 
-                 1  => '发送成功',
 
-                 2  => '等待发送',
 
-                 3  => '发送失败',
 
-             ]);
 
-         });
 
-         $grid->tools(function ($tools) {
 
-             
 
-         });
 
-         return $grid;
 
-     }
 
-     
 
-     protected function detail($id)
 
-     {
 
-         $show = new Show(SmsQueue::findOrFail($id));
 
-         $show->id("ID");
 
-         $show->utype('发送者')->unescape()->as(function ($m_status) {
 
-             switch ($m_status) {
 
-                 case 1:
 
-                     $m_status = '<span class="label label-success">企业</span>';
 
-                     break;
 
-                 case 2:
 
-                     $m_status = '<span class="label label-primary">个人</span>';
 
-                     break;
 
-                 default:
 
-                     $m_status = '<span class="label label-default">系统</span>';
 
-                     break;
 
-             }
 
-             return $m_status;
 
-         });
 
-         $show->s_number('手机号');
 
-         $show->s_body('短信内容');
 
-         $show->s_status('状态')->unescape()->as(function ($m_status) {
 
-             switch ($m_status) {
 
-                 case 1:
 
-                     $m_status = '<span class="label label-success">成功</span>';
 
-                     break;
 
-                 case 2:
 
-                     $m_status = '<span class="label label-warning">等待</span>';
 
-                     break;
 
-                 case 3:
 
-                     $m_status = '<span class="label label-error">失败</span>';
 
-                     break;
 
-                 default:
 
-                     $m_status = '<span class="label label-warning">等待</span>';
 
-                     break;
 
-             }
 
-             return $m_status;
 
-         });
 
-         $show->error_message('错误信息');
 
-         $show->s_sendtime('发送时间');
 
-         $show->created_at('添加时间');
 
-         return $show;
 
-     }
 
-     
 
-     protected function form()
 
-     {
 
-         $form = new Form(new SmsQueue);
 
-         $form->display('ID');
 
-         $form->display('Created at');
 
-         $form->display('Updated at');
 
-         return $form;
 
-     }
 
- }
 
 
  |