123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <?php
- namespace App\Admin\Controllers\Company;
- use App\Http\Controllers\Controller;
- use App\Models\CompanyTpl;
- use App\Models\Tpl;
- use Encore\Admin\Controllers\HasResourceActions;
- use Encore\Admin\Form;
- use Encore\Admin\Grid;
- use Encore\Admin\Layout\Content;
- use Encore\Admin\Show;
- class CompanyTplController extends Controller
- {
- use HasResourceActions;
- /**
- * Index interface.
- *
- * @param Content $content
- * @return Content
- */
- public function index(Content $content)
- {
- return $content
- ->header('企业模版')
- ->description('列表')
- // ->body($this->grid());
- ->body(view('admin.companytpl.index')->with('grid', $this->grid()));
- }
- /**
- * Show interface.
- *
- * @param mixed $id
- * @param Content $content
- * @return Content
- */
- public function show($id, Content $content)
- {
- return $content
- ->header('Detail')
- ->description('description')
- ->body($this->detail($id));
- }
- /**
- * Edit interface.
- *
- * @param mixed $id
- * @param Content $content
- * @return Content
- */
- public function edit($id, Content $content)
- {
- return $content
- ->header('企业模版')
- ->description('编辑')
- // ->body($this->form()->edit($id));
- ->body(view('admin.companytpl.edit')->with('form', $this->editForm()->edit($id)->render()));
- }
- /**
- * Create interface.
- *
- * @param Content $content
- * @return Content
- */
- public function create(Content $content)
- {
- return $content
- ->header('Create')
- ->description('description')
- ->body($this->form());
- }
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $grid = new Grid(new CompanyTpl);
- $grid->id('ID');
- $grid->column('companys.companyname', '企业名称');
- $grid->column('companys.username', '用户名称');
- $grid->column('tpls.images', '缩略图')->image();
- $grid->created_at('添加时间');
- $grid->actions(function ($actions) {
- $actions->disableView();
- });
- $grid->filter(function ($filter) {
- $filter->equal('uid', '企业ID');
- $filter->equal('tplid', '模版ID');
- $filter->like('companys.companyname', '企业名称');
- $filter->like('companys.username', '用户名称');
- });
- return $grid;
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- * @return Show
- */
- protected function detail($id)
- {
- $show = new Show(CompanyTpl::findOrFail($id));
- $show->id('ID');
- $show->created_at('Created at');
- $show->updated_at('Updated at');
- return $show;
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- $form = new Form(new CompanyTpl);
- $form->display('ID');
- $form->display('Created at');
- $form->display('Updated at');
- return $form;
- }
- protected function editForm()
- {
- $form = new Form(new CompanyTpl);
- $form->display('companys.username', '用户名');
- $form->display('uid', '用户ID');
- $form->display('tplid', '模版ID');
- $form->file('tpls.images', '缩略图')->disable();
- $form->tools(function ($tools) {
- $tools->disableView();
- });
- $form->builder(function (Form $form) {
- $form = new Form(new Tpl);
- dd($form);
- });
- return $form;
- }
- }
|