namespace Cubist\Backpack\app\Magic\Models;
+use Backpack\CRUD\app\Http\Controllers\Operations\BulkCloneOperation;
+use Backpack\CRUD\app\Http\Controllers\Operations\BulkDeleteOperation;
+use Backpack\CRUD\app\Http\Controllers\Operations\CloneOperation;
+use Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
+use Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanel;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
+use Backpack\ReviseOperation\ReviseOperation;
+use Composer\DependencyResolver\Operation\UpdateOperation;
+use Cubist\Backpack\app\Http\Controllers\Operations\BulkPublishOperation;
use Cubist\Backpack\app\Magic\BunchOfFields;
use Cubist\Backpack\app\Magic\Controllers\CubistMagicController;
use Cubist\Backpack\app\Magic\EntityData;
protected $primaryKey = 'id';
protected $_operations = [];
public $timestamps = true;
- public $clonable = true;
+
+ protected $_enableClone = true;
+ protected $_enableDeletion = true;
+ protected $_enableEdition = true;
+ protected $_enableCreation = true;
+ protected $_enableRevisions = true;
+ protected $_enableBulk = true;
+
protected $_syncDbSchema = true;
protected $_baseController = CubistMagicController::class;
}
/**
- * @return string
+ * @return stringx
*/
protected function _getBaseController()
{
protected function _getUse()
{
$res = '';
- foreach ($this->_operations as $operation) {
- $res .= 'use ' . $operation . ';' . "\n";
+ $ops = $this->_operations;
+ if ($this->_enableCreation) {
+ $ops[] = CreateOperation::class;
+ }
+ if ($this->_enableEdition) {
+ $ops[] = UpdateOperation::class;
+ if ($this->_enableBulk) {
+ $ops[] = BulkPublishOperation::class;
+ }
+ }
+ if ($this->_enableClone) {
+ $ops[] = CloneOperation::class;
+ if ($this->_enableBulk) {
+ $ops[] = BulkCloneOperation::class;
+ }
+ }
+ if ($this->_enableDeletion) {
+ $ops[] = DeleteOperation::class;
+ if ($this->_enableBulk) {
+ $ops[] = BulkDeleteOperation::class;
+ }
+ }
+ if ($this->_enableRevisions) {
+ $ops[] = ReviseOperation::class;
+ }
+
+ foreach ($ops as $operation) {
+ $res .= 'use \\' . $operation . ';' . "\n\t";
}
+ $res .= "\n";
return $res;
}
'PLURAL' => $this->getOption('plural', ''),
'MODELNAMESPACE' => get_class($this),
'EXTENDS' => '\\' . $this->_getBaseController(),
- 'CLONABLE' => $this->clonable ? 'true' : 'false',
'BULK' => $this->getOption('bulk', true) ? 'true' : 'false',
'ONEINSTANCE' => $this->getOption('oneinstance', false) ? 'true' : 'false',
'USE' => $this->_getUse()];