Showing
1 changed file
with
112 additions
and
0 deletions
app/Admin/Controllers/PushController.php
0 → 100755
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Admin\Controllers; | ||
| 4 | + | ||
| 5 | +use App\Models\Push; | ||
| 6 | +use Dcat\Admin\Form; | ||
| 7 | +use Dcat\Admin\Grid; | ||
| 8 | +use Dcat\Admin\Show; | ||
| 9 | +use Dcat\Admin\Http\Controllers\AdminController; | ||
| 10 | + | ||
| 11 | +class PushController extends AdminController | ||
| 12 | +{ | ||
| 13 | + protected $title = '推送服务'; | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * Make a grid builder. | ||
| 17 | + * | ||
| 18 | + * @return Grid | ||
| 19 | + */ | ||
| 20 | + protected function grid() | ||
| 21 | + { | ||
| 22 | + return Grid::make(new Push(), function (Grid $grid) { | ||
| 23 | + $grid->column('id')->sortable(); | ||
| 24 | + $grid->column('title'); | ||
| 25 | + $grid->column('terminal'); | ||
| 26 | + $grid->column('push_type'); | ||
| 27 | + $grid->column('push_time'); | ||
| 28 | + $grid->column('action_type'); | ||
| 29 | + $grid->column('user_type'); | ||
| 30 | + $grid->column('updated_at')->sortable(); | ||
| 31 | + | ||
| 32 | + $grid->filter(function (Grid\Filter $filter) { | ||
| 33 | + $filter->equal('id'); | ||
| 34 | + | ||
| 35 | + }); | ||
| 36 | + }); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * Make a show builder. | ||
| 41 | + * | ||
| 42 | + * @param mixed $id | ||
| 43 | + * | ||
| 44 | + * @return Show | ||
| 45 | + */ | ||
| 46 | + protected function detail($id) | ||
| 47 | + { | ||
| 48 | + return Show::make($id, new Push(), function (Show $show) { | ||
| 49 | + $show->field('id'); | ||
| 50 | + $show->field('title'); | ||
| 51 | + $show->field('terminal'); | ||
| 52 | + $show->field('push_type'); | ||
| 53 | + $show->field('push_time'); | ||
| 54 | + $show->field('action_type'); | ||
| 55 | + $show->field('user_type'); | ||
| 56 | + $show->field('updated_at'); | ||
| 57 | + }); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * Make a form builder. | ||
| 62 | + * | ||
| 63 | + * @return Form | ||
| 64 | + */ | ||
| 65 | + protected function form() | ||
| 66 | + { | ||
| 67 | + return Form::make(new Push(), function (Form $form) { | ||
| 68 | + $form->display('id'); | ||
| 69 | + | ||
| 70 | + $form->block(8, function (Form\BlockForm $form) { | ||
| 71 | + // 设置标题 | ||
| 72 | + $form->title('基本设置'); | ||
| 73 | + // 显示底部提交按钮 | ||
| 74 | + $form->showFooter(); | ||
| 75 | + // 设置字段宽度 | ||
| 76 | + $form->width(8, 3); | ||
| 77 | + | ||
| 78 | + $form->radio('terminal')->addElementClass('terminal') | ||
| 79 | + ->options([1 => 'Android', 2 => 'IOS'])->default(2); | ||
| 80 | + | ||
| 81 | + $form->text('title')->addElementClass('title'); | ||
| 82 | + $form->textarea('content')->addElementClass('push_content'); | ||
| 83 | + | ||
| 84 | + $form->radio('push_type', '发送时间')->addElementClass('push_type') | ||
| 85 | + ->options([1 => '立即', 2 => '定时'])->default(1) | ||
| 86 | + ->when(2, function (Form\BlockForm $form) { | ||
| 87 | + $form->datetime('push_time'); | ||
| 88 | + }); | ||
| 89 | + $form->select('action_type')->addElementClass('action_type') | ||
| 90 | + ->options(['打开应用', '临境', '会员介绍页', '众妙页']); | ||
| 91 | + | ||
| 92 | + $form->radio('user_type', '目标人群')->options([1 => '所有人', 2 => '指定用户'])->default(1) | ||
| 93 | + ->when(2, function (Form\BlockForm $form) { | ||
| 94 | + $form->text('user_id')->placeholder("多个用户用逗号,分开"); | ||
| 95 | + }); | ||
| 96 | + }); | ||
| 97 | + | ||
| 98 | + $form->block(4, function (Form\BlockForm $form) { | ||
| 99 | + $form->width(9, 1); | ||
| 100 | + $form->html(view('admin.form.push')); | ||
| 101 | + }); | ||
| 102 | + | ||
| 103 | + $form->display('created_at'); | ||
| 104 | + $form->display('updated_at'); | ||
| 105 | + }); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public function store() | ||
| 109 | + { | ||
| 110 | + dd(request()->all()); | ||
| 111 | + } | ||
| 112 | +} |
-
Please register or login to post a comment