$this->crud->setRoute(config('backpack.base.route_prefix') . '/model');
$this->crud->setEntityNameStrings('model', 'models');
+
/*
|--------------------------------------------------------------------------
| CrudPanel Configuration
'label' => 'Model table name',
'column' => true], 'create');
$this->addField(['type' => 'text', 'name' => 'label', 'label' => 'Model label', 'column' => true], 'both');
- $this->addField(['type' => 'select2_from_ajax_multiple', 'name' => 'fields', 'label' => 'Fields definitions'], 'both');
+
+ $this->addField([
+ 'name' => 'fields',
+ 'type' => 'select2_from_ajax_multiple',
+ 'label' => 'Fields definitions',
+ 'view_namespace' => 'webfactor::fields',
+ 'model' => Entity::class,
+ 'entity' => 'modelfield',
+ 'attribute' => 'name',
+ 'placeholder' => 'Choose',
+ 'pagination' => 20, // optional, default: 10
+ 'minimum_input_length' => 0,
+ 'on_the_fly' => [
+ 'entity' => 'modelfield', // e. g. user, contact, company etc...
+ 'create' => true,
+ 'edit' => true,
+ 'delete' => true,
+ ]], 'both');
// add asterisk for fields that are required in ModelRequest
$this->crud->setRequiredFields(StoreRequest::class, 'create');
--- /dev/null
+<?php
+
+
+namespace Cubist\Backpack\app\Http\Controllers;
+
+use Backpack\CRUD\app\Http\Controllers\CrudController;
+
+// VALIDATION: change the requests to match your own file names if you need form validation
+use Cubist\Backpack\app\Http\Requests\CubistModelRequest as StoreRequest;
+use Cubist\Backpack\app\Http\Requests\CubistModelRequest as UpdateRequest;
+use Webfactor\Laravel\Backpack\InstantFields\InstantFields;
+
+
+class CubistModelFieldCrudController extends CrudController
+{
+ use CubistCrud;
+ use InstantFields;
+
+ public function setup()
+ {
+ /*
+ |--------------------------------------------------------------------------
+ | CrudPanel Basic Information
+ |--------------------------------------------------------------------------
+ */
+ $this->crud->setModel('Cubist\Backpack\app\Models\CubistModelField');
+ $this->crud->setRoute(config('backpack.base.route_prefix') . '/modelfield');
+ $this->crud->setEntityNameStrings('modelfield', 'modelfieldss');
+
+
+ $this->setAjaxEntity('modelfield');
+
+ /*
+ |--------------------------------------------------------------------------
+ | CrudPanel Configuration
+ |--------------------------------------------------------------------------
+ */
+
+ $this->addField(['type' => 'text',
+ 'name' => 'name',
+ 'label' => 'Field column name',
+ 'column' => true], 'create');
+ $this->addField(['type' => 'text', 'name' => 'label', 'label' => 'Field label', 'column' => true], 'both');
+ $this->addField(['type' => 'table', 'name' => 'attributes', 'label' => 'Attributes'], 'both');
+
+ // add asterisk for fields that are required in ModelRequest
+ $this->crud->setRequiredFields(StoreRequest::class, 'create');
+ $this->crud->setRequiredFields(UpdateRequest::class, 'edit');
+ }
+
+ public function store(StoreRequest $request)
+ {
+ // your additional operations before save here
+ $redirect_location = parent::storeCrud($request);
+ // your additional operations after save here
+ // use $this->data['entry'] or $this->crud->entry
+ return $redirect_location;
+ }
+
+ public function update(UpdateRequest $request)
+ {
+ // your additional operations before save here
+ $redirect_location = parent::updateCrud($request);
+ // your additional operations after save here
+ // use $this->data['entry'] or $this->crud->entry
+ return $redirect_location;
+ }
+}
+