The Controller

Setup

use \Vortechron\Essentials\Traits\Controller\Essentials;

Instead of

use \Vortechron\Essentials\Traits\Controller\HasCrud;
use \Vortechron\Essentials\Traits\Controller\HasMeta;
use \Vortechron\Essentials\Traits\Controller\HasHelpers;

Full Example

<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Page;
use Illuminate\Http\Request;
class PageController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$this->prepareIndexData(
Page::class,
'Manage Pages'
);
$this->prepareAction('Create Page', route('admin.pages.create'));
return view('admin.page.index');
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$this->prepareData(
(new Page)->forModel(),
'Create Page',
route('admin.pages.store'),
'',
route('admin.pages.index')
);
return view('admin.page.template');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$request->validate([
'title' => 'required',
'content' => 'required',
]);
$page = Page::create($request->except('_token', '_redirect'));
$page->saveMedia($request->social_image, 'social');
flashSaved();
return $this->handleRedirect(route('admin.pages.edit', $page), route('admin.pages.index'));
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Page $page
* @return \Illuminate\Http\Response
*/
public function edit(Page $page)
{
$this->prepareData(
$page->forModel(),
'Edit Page',
route('admin.pages.update', $page),
route('admin.pages.destroy', $page),
route('admin.pages.index')
);
return view('admin.page.template');
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Page $page
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Page $page)
{
$request->validate([
'title' => 'required',
'content' => 'required',
]);
$page->update($request->except('_token', '_redirect'));
$page->saveMedia($request->social_image, 'social');
flashSaved();
return $this->handleRedirect(route('admin.pages.edit', $page), route('admin.pages.index'));
}
/**
* Remove the specified resource from storage.
*
* @param \App\Page $page
* @return \Illuminate\Http\Response
*/
public function destroy(Page $page)
{
$page->delete();
flashDeleted();
return redirect()->route('admin.pages.index');
}
}