123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace App\Admin\Controllers;
- use App\Models\Config;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- class RecommendationsController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new Config(), function (Grid $grid) {
- $grid->model()->whereIn('id',[3,13,4]);
- $grid->column('id')->sortable();
- $grid->column('desc','标题');
- $grid->column('value','值')->display(function ($item){
- if ($this->id == 3){
- return $item.'%';
- }
- if ($this->id == 4){
- return $item.'元';
- }
- return $item;
- });
- $grid->column('created_at');
- $grid->column('updated_at')->sortable();
- $grid->disableDeleteButton();
- $grid->disableCreateButton();
- $grid->disableViewButton();
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new Config(), function (Show $show) {
- $show->field('id');
- $show->field('key');
- $show->field('value');
- $show->field('desc');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new Config(), function (Form $form) {
- $form->display('id');
- $form->text('value','值')->required();
- $form->display('desc','标题');
- $form->disableViewButton();
- $form->disableDeleteButton();
- });
- }
- }
|