ExportCrudController::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 19
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Http\Controllers\Frontend;
4
5
use App\Http\Requests\Frontend\ExportRequest as StoreRequest;
6
// VALIDATION: change the requests to match your own file names if you need form validation
7
use App\Http\Requests\Frontend\ExportRequest as UpdateRequest;
8
use App\Models\Export;
9
use Backpack\CRUD\app\Http\Controllers\CrudController;
10
11
class ExportCrudController extends CrudController
12
{
13
    public function setUp()
14
    {
15
16
        /*
17
        |--------------------------------------------------------------------------
18
        | BASIC CRUD INFORMATION
19
        |--------------------------------------------------------------------------
20
        */
21
        $this->crud->setModel(Export::class);
22
        $this->crud->setRoute(config('backpack.base.route_prefix') . '/export');
23
        $this->crud->setEntityNameStrings('export', 'exports');
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
55
        // ------ CRUD ACCESS
56
        // $this->crud->allowAccess(['list', 'create', 'update', 'reorder', 'delete']);
57
        // $this->crud->denyAccess(['list', 'create', 'update', 'reorder', 'delete']);
58
59
        // ------ CRUD REORDER
60
        // $this->crud->enableReorder('label_name', MAX_TREE_LEVEL);
61
        // NOTE: you also need to do allow access to the right users: $this->crud->allowAccess('reorder');
62
63
        // ------ CRUD DETAILS ROW
64
        // $this->crud->enableDetailsRow();
65
        // NOTE: you also need to do allow access to the right users: $this->crud->allowAccess('details_row');
66
        // 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
67
68
        // ------ REVISIONS
69
        // You also need to use \Venturecraft\Revisionable\RevisionableTrait;
70
        // Please check out: https://laravel-backpack.readme.io/docs/crud#revisions
71
        // $this->crud->allowAccess('revisions');
72
73
        // ------ AJAX TABLE VIEW
74
        // Please note the drawbacks of this though:
75
        // - 1-n and n-n columns are not searchable
76
        // - date and datetime columns won't be sortable anymore
77
        // $this->crud->enableAjaxTable();
78
79
        // ------ DATATABLE EXPORT BUTTONS
80
        // Show export to PDF, CSV, XLS and Print buttons on the table view.
81
        // Does not work well with AJAX datatables.
82
        // $this->crud->enableExportButtons();
83
84
        // ------ ADVANCED QUERIES
85
        // $this->crud->addClause('active');
86
        // $this->crud->addClause('type', 'car');
87
        // $this->crud->addClause('where', 'name', '==', 'car');
88
        // $this->crud->addClause('whereName', 'car');
89
        // $this->crud->addClause('whereHas', 'posts', function($query) {
90
        //     $query->activePosts();
91
        // });
92
        // $this->crud->addClause('withoutGlobalScopes');
93
        // $this->crud->addClause('withoutGlobalScope', VisibleScope::class);
94
        // $this->crud->with(); // eager load relationships
95
        // $this->crud->orderBy();
96
        // $this->crud->groupBy();
97
        // $this->crud->limit();
98
    }
99
100
    public function store(StoreRequest $request)
101
    {
102
        // your additional operations before save here
103
        $redirect_location = parent::storeCrud();
104
        // your additional operations after save here
105
        // use $this->data['entry'] or $this->crud->entry
106
        return $redirect_location;
107
    }
108
109
    public function update(UpdateRequest $request)
110
    {
111
        // your additional operations before save here
112
        $redirect_location = parent::updateCrud();
113
        // your additional operations after save here
114
        // use $this->data['entry'] or $this->crud->entry
115
        return $redirect_location;
116
    }
117
}
118