--- /dev/null
+<?php
+
+
+namespace Cubist\Backpack\app\Http\Controllers;
+
+trait CubistCrudController
+{
+ public function addField($field, $form = 'both')
+ {
+ if (isset($field['column_label']) || isset($field['column']) && $field['column'] == true) {
+ $column_data = ['name' => $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);
+ }
+}
*/
class CubistModelCrudController extends CrudController
{
+ use CubistCrudController;
+
public function setup()
{
/*
|--------------------------------------------------------------------------
*/
- $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');