| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- namespace Dcat\Admin\Controllers;
- use Dcat\Admin\Layout\Content;
- use Illuminate\Routing\Controller;
- class AdminController extends Controller
- {
- use HasResourceActions;
- /**
- * Title for current resource.
- *
- * @var string
- */
- protected $title = 'Title';
- /**
- * Set description for following 4 action pages.
- *
- * @var array
- */
- protected $description = [
- // 'index' => 'Index',
- // 'show' => 'Show',
- // 'edit' => 'Edit',
- // 'create' => 'Create',
- ];
- /**
- * Get content title.
- *
- * @return string
- */
- protected function title()
- {
- return $this->title;
- }
- /**
- * Index interface.
- *
- * @param Content $content
- *
- * @return Content
- */
- public function index(Content $content)
- {
- return $content
- ->title($this->title())
- ->description($this->description['index'] ?? trans('admin.list'))
- ->body($this->grid());
- }
- /**
- * Show interface.
- *
- * @param mixed $id
- * @param Content $content
- *
- * @return Content
- */
- public function show($id, Content $content)
- {
- return $content
- ->title($this->title())
- ->description($this->description['show'] ?? trans('admin.show'))
- ->body($this->detail($id));
- }
- /**
- * Edit interface.
- *
- * @param mixed $id
- * @param Content $content
- *
- * @return Content
- */
- public function edit($id, Content $content)
- {
- return $content
- ->title($this->title())
- ->description($this->description['edit'] ?? trans('admin.edit'))
- ->body($this->form()->edit($id));
- }
- /**
- * Create interface.
- *
- * @param Content $content
- *
- * @return Content
- */
- public function create(Content $content)
- {
- return $content
- ->title($this->title())
- ->description($this->description['create'] ?? trans('admin.create'))
- ->body($this->form());
- }
- }
|