|
@@ -0,0 +1,159 @@
|
|
|
|
+<?php
|
|
|
|
+
|
|
|
|
+namespace App\Admin\Controllers;
|
|
|
|
+
|
|
|
|
+use Dcat\Admin\Layout\Content;
|
|
|
|
+use Illuminate\Routing\Controller;
|
|
|
|
+
|
|
|
|
+class AdminController extends Controller
|
|
|
|
+{
|
|
|
|
+ /**
|
|
|
|
+ * Title for current resource.
|
|
|
|
+ *
|
|
|
|
+ * @var string
|
|
|
|
+ */
|
|
|
|
+ protected $title;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Set description for following 4 action pages.
|
|
|
|
+ *
|
|
|
|
+ * @var array
|
|
|
|
+ */
|
|
|
|
+ protected $description = [
|
|
|
|
+ // 'index' => 'Index',
|
|
|
|
+ // 'show' => 'Show',
|
|
|
|
+ // 'edit' => 'Edit',
|
|
|
|
+ // 'create' => 'Create',
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Set translation path.
|
|
|
|
+ *
|
|
|
|
+ * @var string
|
|
|
|
+ */
|
|
|
|
+ protected $translation;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Get content title.
|
|
|
|
+ *
|
|
|
|
+ * @return string
|
|
|
|
+ */
|
|
|
|
+ protected function title()
|
|
|
|
+ {
|
|
|
|
+ return $this->title ?: admin_trans_label();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Get description for following 4 action pages.
|
|
|
|
+ *
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ protected function description()
|
|
|
|
+ {
|
|
|
|
+ return $this->description;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Get translation path.
|
|
|
|
+ *
|
|
|
|
+ * @return string
|
|
|
|
+ */
|
|
|
|
+ protected function translation()
|
|
|
|
+ {
|
|
|
|
+ return $this->translation;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Index interface.
|
|
|
|
+ *
|
|
|
|
+ * @param Content $content
|
|
|
|
+ * @return Content
|
|
|
|
+ */
|
|
|
|
+ public function index($parent, Content $content)
|
|
|
|
+ {
|
|
|
|
+ return $content
|
|
|
|
+ ->translation($this->translation())
|
|
|
|
+ ->title($this->title())
|
|
|
|
+ ->description($this->description()['index'] ?? trans('admin.list'))
|
|
|
|
+ ->body($this->grid($parent));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Show interface.
|
|
|
|
+ *
|
|
|
|
+ * @param mixed $id
|
|
|
|
+ * @param Content $content
|
|
|
|
+ * @return Content
|
|
|
|
+ */
|
|
|
|
+ public function show($parent, $id, Content $content)
|
|
|
|
+ {
|
|
|
|
+ return $content
|
|
|
|
+ ->translation($this->translation())
|
|
|
|
+ ->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($parent, $id, Content $content)
|
|
|
|
+ {
|
|
|
|
+ return $content
|
|
|
|
+ ->translation($this->translation())
|
|
|
|
+ ->title($this->title())
|
|
|
|
+ ->description($this->description()['edit'] ?? trans('admin.edit'))
|
|
|
|
+ ->body($this->form($parent)->edit($id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Create interface.
|
|
|
|
+ *
|
|
|
|
+ * @param Content $content
|
|
|
|
+ * @return Content
|
|
|
|
+ */
|
|
|
|
+ public function create($parent, Content $content)
|
|
|
|
+ {
|
|
|
|
+ return $content
|
|
|
|
+ ->translation($this->translation())
|
|
|
|
+ ->title($this->title())
|
|
|
|
+ ->description($this->description()['create'] ?? trans('admin.create'))
|
|
|
|
+ ->body($this->form($parent));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Update the specified resource in storage.
|
|
|
|
+ *
|
|
|
|
+ * @param int $id
|
|
|
|
+ * @return \Illuminate\Http\Response
|
|
|
|
+ */
|
|
|
|
+ public function update($parent, $id)
|
|
|
|
+ {
|
|
|
|
+ return $this->form($parent)->update($id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Store a newly created resource in storage.
|
|
|
|
+ *
|
|
|
|
+ * @return mixed
|
|
|
|
+ */
|
|
|
|
+ public function store($parent)
|
|
|
|
+ {
|
|
|
|
+ return $this->form($parent)->store();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Remove the specified resource from storage.
|
|
|
|
+ *
|
|
|
|
+ * @param int $id
|
|
|
|
+ * @return \Illuminate\Http\Response
|
|
|
|
+ */
|
|
|
|
+ public function destroy($parent, $id)
|
|
|
|
+ {
|
|
|
|
+ return $this->form($parent)->destroy($id);
|
|
|
|
+ }
|
|
|
|
+}
|