ElementAttributeCrudController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 107
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 9
dl 0
loc 107
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 7 1
A store() 0 7 1
A setup() 0 19 1
1
<?php
2
3
namespace App\Http\Controllers\Frontend\Elementset;
4
5
use App\Http\Requests\Frontend\Elementset\ElementAttributeRequest as StoreRequest;
6
// VALIDATION: change the requests to match your own file names if you need form validation
7
use App\Http\Requests\Frontend\Elementset\ElementAttributeRequest as UpdateRequest;
8
use App\Models\ElementAttribute;
9
use Backpack\CRUD\app\Http\Controllers\CrudController;
10
11
class ElementAttributeCrudController extends CrudController
12
{
13
    public function setup()
14
    {
15
16
        /*
17
        |--------------------------------------------------------------------------
18
        | BASIC CRUD INFORMATION
19
        |--------------------------------------------------------------------------
20
        */
21
        $this->crud->setModel(ElementAttribute::class);
22
        $this->crud->setRoute(config('backpack.base.route_prefix') . '/elementattribute');
23
        $this->crud->setEntityNameStrings('elementattribute', 'element_attributes');
24
25
        /*
26
        |--------------------------------------------------------------------------
27
        | BASIC CRUD INFORMATION
28
        |--------------------------------------------------------------------------
29
        */
30
31
        $this->crud->setFromDb();
32
33
        // ------ CRUD FIELDS
34
        // $this->crud->addField($options, 'update/create/both');
35
        // $this->crud->addFields($array_of_arrays, 'update/create/both');
36
        // $this->crud->removeField('name', 'update/create/both');
37
        // $this->crud->removeFields($array_of_names, 'update/create/both');
38
39
        // ------ CRUD COLUMNS
40
        // $this->crud->addColumn(); // add a single column, at the end of the stack
41
        // $this->crud->addColumns(); // add multiple columns, at the end of the stack
42
        // $this->crud->removeColumn('column_name'); // remove a column from the stack
43
        // $this->crud->removeColumns(['column_name_1', 'column_name_2']); // remove an array of columns from the stack
44
        // $this->crud->setColumnDetails('column_name', ['attribute' => 'value']); // adjusts the properties of the passed in column (by name)
45
        // $this->crud->setColumnsDetails(['column_1', 'column_2'], ['attribute' => 'value']);
46
47
        // ------ CRUD BUTTONS
48
        // possible positions: 'beginning' and 'end'; defaults to 'beginning' for the 'line' stack, 'end' for the others;
49
        // $this->crud->addButton($stack, $name, $type, $content, $position); // add a button; possible types are: view, model_function
50
        // $this->crud->addButtonFromModelFunction($stack, $name, $model_function_name, $position); // add a button whose HTML is returned by a method in the CRUD model
51
        // $this->crud->addButtonFromView($stack, $name, $view, $position); // add a button whose HTML is in a view placed at resources\views\vendor\backpack\crud\buttons
52
        // $this->crud->removeButton($name);
53
        // $this->crud->removeButtonFromStack($name, $stack);
54
        // $this->crud->removeAllButtons();
55
        // $this->crud->removeAllButtonsFromStack('line');
56
57
        // ------ CRUD ACCESS
58
        // $this->crud->allowAccess(['list', 'create', 'update', 'reorder', 'delete']);
59
        // $this->crud->denyAccess(['list', 'create', 'update', 'reorder', 'delete']);
60
61
        // ------ CRUD REORDER
62
        // $this->crud->enableReorder('label_name', MAX_TREE_LEVEL);
63
        // NOTE: you also need to do allow access to the right users: $this->crud->allowAccess('reorder');
64
65
        // ------ CRUD DETAILS ROW
66
        // $this->crud->enableDetailsRow();
67
        // NOTE: you also need to do allow access to the right users: $this->crud->allowAccess('details_row');
68
        // NOTE: you also need to do overwrite the showDetailsRow($id) method in your EntityCrudController to show whatever you'd like in the details row OR overwrite the views/backpack/crud/details_row.blade.php
69
70
        // ------ REVISIONS
71
        // You also need to use \Venturecraft\Revisionable\RevisionableTrait;
72
        // Please check out: https://laravel-backpack.readme.io/docs/crud#revisions
73
        // $this->crud->allowAccess('revisions');
74
75
        // ------ AJAX TABLE VIEW
76
        // Please note the drawbacks of this though:
77
        // - 1-n and n-n columns are not searchable
78
        // - date and datetime columns won't be sortable anymore
79
        // $this->crud->enableAjaxTable();
80
81
        // ------ DATATABLE EXPORT BUTTONS
82
        // Show export to PDF, CSV, XLS and Print buttons on the table view.
83
        // Does not work well with AJAX datatables.
84
        // $this->crud->enableExportButtons();
85
86
        // ------ ADVANCED QUERIES
87
        // $this->crud->addClause('active');
88
        // $this->crud->addClause('type', 'car');
89
        // $this->crud->addClause('where', 'name', '==', 'car');
90
        // $this->crud->addClause('whereName', 'car');
91
        // $this->crud->addClause('whereHas', 'posts', function($query) {
92
        //     $query->activePosts();
93
        // });
94
        // $this->crud->addClause('withoutGlobalScopes');
95
        // $this->crud->addClause('withoutGlobalScope', VisibleScope::class);
96
        // $this->crud->with(); // eager load relationships
97
        // $this->crud->orderBy();
98
        // $this->crud->groupBy();
99
        // $this->crud->limit();
100
    }
101
102
    public function store(StoreRequest $request)
103
    {
104
        // your additional operations before save here
105
        $redirect_location = parent::storeCrud();
106
        // your additional operations after save here
107
        // use $this->data['entry'] or $this->crud->entry
108
        return $redirect_location;
109
    }
110
111
    public function update(UpdateRequest $request)
112
    {
113
        // your additional operations before save here
114
        $redirect_location = parent::updateCrud();
115
        // your additional operations after save here
116
        // use $this->data['entry'] or $this->crud->entry
117
        return $redirect_location;
118
    }
119
}
120