| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?php
- namespace UCore\DcatAdmin\Traits;
- use App\Admin\Jz\LazyRenderable\TeamInfo;
- use Dcat\Admin\Admin;
- use Dcat\Admin\Layout\Content;
- trait ResController
- {
- /**
- * Index interface.
- *
- * @param Content $content
- * @return Content
- */
- public function index(Content $content)
- {
- $res = $this->callContent($content);
- if($res){
- return $res;
- }
- return $content
- ->translation($this->translation())
- ->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)
- {
- $res = $this->callContent($content);
- if ($res) {
- return $res;
- }
- return $content
- ->translation($this->translation())
- ->body($this->detail($id))
- ->title($this->title())
- ->description($this->description()['show'] ?? trans('admin.show'));
- }
- /**
- * Edit interface.
- *
- * @param mixed $id
- * @param Content $content
- * @return Content
- */
- public function edit($id, Content $content)
- {
- $res = $this->callContent($content);
- if ($res) {
- return $res;
- }
- return $content
- ->translation($this->translation())
- ->body($this->form()->edit($id)->title($this->title()))
- ->title($this->title())
- ->description($this->description()['edit'] ?? trans('admin.edit'));
- }
- /**
- * Create interface.
- *
- * @param Content $content
- * @return Content
- */
- public function create(Content $content)
- {
- $res = $this->callContent($content);
- if($res){
- return $res;
- }
- return $content
- ->translation($this->translation())
- ->title($this->title())
- ->description($this->description()['create'] ?? trans('admin.create'))
- ->body($this->form());
- }
- /**
- * Update the specified resource in storage.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function update($id)
- {
- return $this->form()->update($id);
- }
- /**
- * Store a newly created resource in storage.
- *
- * @return mixed
- */
- public function store()
- {
- return $this->form()->store();
- }
- /**
- * Remove the specified resource from storage.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function destroy($id)
- {
- return $this->form()->destroy($id);
- }
- public function callContent(Content &$content)
- {
- if (request()->header('Sec-Fetch-Dest') == 'iframe'|| request('in_iframe')) {
- $content->full();
- Admin::disablePjax();
- }
- if (request()->header('Sec-Fetch-Dest') == 'iframe' && !request('in_iframe')) {
- return admin_redirect('/iframe?to=' . url()->current());
- }
- }
- }
|