use Cubist\Backpack\app\Magic\Requests\CubistMagicStoreRequest;
use Cubist\Backpack\app\Magic\Requests\CubistMagicUpdateRequest;
use Illuminate\Support\Arr;
+use Illuminate\Support\Facades\Redirect;
trait CubistMagicControllerTrait
{
$this->_plural = $this->_singular . 's';
}
- if ($this->_clonable) {
- $this->crud->allowAccess('clone');
- }
- if($this->_oneInstance){
- $this->crud->addClause('where', 'id', 1);
+ if ($this->_oneInstance) {
$this->crud->denyAccess(['create', 'delete']);
- }else{
+ } else {
$this->crud->setCreateView('cubist_back::create');
+ if ($this->_clonable) {
+ $this->crud->allowAccess('clone');
+ }
+ $this->crud->enableExportButtons();
+ $this->crud->enablePersistentTable();
}
$this->crud->allowAccess('revisions');
- $this->crud->enablePersistentTable();
$this->crud->setEditView('cubist_back::edit');
- $this->crud->enableExportButtons();
+
// $this->crud->with('revisionHistory');
return $redirect_location;
}
+
+ public function index()
+ {
+ if ($this->_oneInstance) {
+ return Redirect::to('admin/' . $this->_routeURL . '/1/edit');
+ }
+ return parent::index();
+ }
+
public function edit($id)
{
+ if ($this->_oneInstance) {
+ $id = 1;
+ }
$this->getModelInstance()->onBeforeEdit($this, $id);
return parent::edit($id);
}