From: Vincent Vanwaelscappel Date: Tue, 21 May 2019 16:05:12 +0000 (+0200) Subject: #2783 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=83c0499932bcc94c98563f370a4b3d5728f46b55;p=cubist_cms-back.git #2783 --- diff --git a/src/app/Http/Controllers/CubistCrudController.php b/src/app/Http/Controllers/CubistCrudController.php new file mode 100644 index 0000000..b974569 --- /dev/null +++ b/src/app/Http/Controllers/CubistCrudController.php @@ -0,0 +1,27 @@ + $field['name'], 'label' => $field['label'], 'type' => 'text']; + if (isset($field['column'])) { + unset($field['column']); + } + if (isset($field['column_label'])) { + $column_data['label'] = $field['column_label']; + unset($field['column_label']); + } + if (isset($field['column_type'])) { + $column_data['type'] = $field['column_type']; + unset($column_data['type']); + } + $this->crud->addColumn($column_data); + } + $this->crud->addField($field, $form); + } +} diff --git a/src/app/Http/Controllers/CubistModelCrudController.php b/src/app/Http/Controllers/CubistModelCrudController.php index ac06050..c944fbe 100644 --- a/src/app/Http/Controllers/CubistModelCrudController.php +++ b/src/app/Http/Controllers/CubistModelCrudController.php @@ -16,6 +16,8 @@ use Backpack\CRUD\CrudPanel; */ class CubistModelCrudController extends CrudController { + use CubistCrudController; + public function setup() { /* @@ -33,9 +35,12 @@ class CubistModelCrudController extends CrudController |-------------------------------------------------------------------------- */ - $this->crud->addField(['type' => 'text', 'name' => 'name', 'label' => 'Template table name'], 'create'); - $this->crud->addField(['type' => 'text', 'name' => 'label', 'label' => 'Tamplate label'], 'both'); - $this->crud->addField(['type' => 'textarea', 'name' => 'attributes', 'label' => 'Fields definitions'], 'both'); + $this->addField(['type' => 'text', + 'name' => 'name', + 'label' => 'Model table name', + 'column' => true], 'create'); + $this->addField(['type' => 'text', 'name' => 'label', 'label' => 'Model label', 'column' => true], 'both'); + $this->addField(['type' => 'textarea', 'name' => 'attributes', 'label' => 'Fields definitions'], 'both'); // add asterisk for fields that are required in ModelRequest $this->crud->setRequiredFields(StoreRequest::class, 'create');