| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace App\Admin\Controllers;
- use App\Admin\Actions\Notice\NoticeSend;
- use App\Models\Notice;
- use App\Models\User;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- use Faker\Factory;
- class NoticeController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $grid = new Grid(new Notice());
- $grid->model()->orderBy('id','desc');
- $grid->column('id')->sortable();
- $grid->column('title');
- $grid->column('content')->limit(60);
- $grid->column('users')->using(['全部用户','男性用户','女性用户'])->label(['success','primary','warning']);
- $grid->column('created_at');
- //$grid->column('updated_at')->sortable();
- $grid->filter(function (Grid\Filter $filter) {
- $filter->equal('id');
- });
- //操作管理
- // $grid->actions(function (Grid\Displayers\Actions $actions) {
- // $actions->append(new NoticeSend(User::class));
- // });
- return $grid;
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new Notice(), function (Show $show) {
- $show->field('id');
- $show->field('title');
- $show->field('content')->unescape();
- $show->field('users')->using(['全部用户','男性用户','女性用户']);
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new Notice(), function (Form $form) {
- $form->display('id');
- $form->text('title');
- $form->editor('content');
- $form->radio('users')->options([0=>'全部用户',1=>'男性用户',2=>"女性用户"])->default(0);
- $form->display('created_at');
- $form->display('updated_at');
- });
- }
- }
|