123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- namespace App\Admin\Controllers;
- use App\Admin\Repositories\Anchor;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Admin;
- use Dcat\Admin\Http\Controllers\AdminController;
- use Illuminate\Support\Facades\Log;
- use function PHPSTORM_META\type;
- class AnchorController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new Anchor(), function (Grid $grid) {
- $grid->column('id')->sortable();
- $grid->column('name');
- $grid->column('status')->using([
- 1 => '正常',
- 2 => '封禁',
- 9 => '删除',
- ])->label([
- 1 => Admin::color()->success(80),
- 2 => Admin::color()->danger(60),
- 9 => Admin::color()->warning(60),
- ]);
- // $grid->column('live_room_id');
- // $grid->column('admin_users_id');
- // $grid->column('created_at');
- // $grid->column('updated_at')->sortable();
- $grid->fixColumns(0, -1); //设置固定栏目
- $grid->disableViewButton(); //禁用详情
- $grid->disableBatchDelete(); //禁用批量删除
- $grid->disableDeleteButton(); //禁用删除
- $grid->filter(function (Grid\Filter $filter) {
- $filter->equal('id');
- });
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new Anchor(), function (Show $show) {
- $show->field('id');
- $show->field('status');
- $show->field('live_room_id');
- $show->field('name');
- $show->field('admin_users_id');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new Anchor(), function (Form $form) {
- // $form->display('id');
- // $form->divider('目前只支持管理员修改,无权限请勿修改');
- // $form->text('password', '密码')->required();
- $form->text('name');
- $form->select('status', '状态')->options([
- 1 => '正常',
- 2 => '封禁',
- // 9 => '删除',
- ])->required();
- $form->text('app_id')->help('请勿随意修改,否则会导致无法提单');
- $form->text('app_secret')->help('请勿随意修改,否则会导致无法提单');
-
- // $form->saving(function (Form $form) {
- // if($form->password == "123"){
- // // return 1;
- // }
- // });
- $form->saved(function (Form $form) {
- Log::info('修改主播:' . $form->name);
- Log::info(json_encode($form->model(), JSON_UNESCAPED_UNICODE));
- });
- // $form->text('live_room_id');
- // $form->text('admin_users_id');
- // $form->display('created_at');
- // $form->display('updated_at');
- });
- }
- }
|