|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Requests\ClassificationCrudRequest as StoreRequest; |
|
6
|
|
|
use App\Http\Requests\ClassificationCrudRequest as UpdateRequest; |
|
7
|
|
|
use Backpack\CRUD\app\Http\Controllers\CrudController; |
|
8
|
|
|
|
|
9
|
|
|
class ClassificationCrudController extends CrudController |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* Prepare the admin interface by setting the associated |
|
13
|
|
|
* model, setting the route, and adding custom columns/fields. |
|
14
|
|
|
* |
|
15
|
|
|
* @return void |
|
16
|
|
|
*/ |
|
17
|
|
|
public function setup() : void |
|
18
|
|
|
{ |
|
19
|
|
|
// Eloquent model to associate with this collection of views and controller actions. |
|
20
|
|
|
$this->crud->setModel('App\Models\Classification'); |
|
21
|
|
|
// Custom backpack route. |
|
22
|
|
|
$this->crud->setRoute('admin/classification'); |
|
23
|
|
|
// Custom strings to display within the backpack UI. |
|
24
|
|
|
$this->crud->setEntityNameStrings('classification', 'classifications'); |
|
25
|
|
|
// No deleting classifications. |
|
26
|
|
|
$this->crud->denyAccess('delete'); |
|
27
|
|
|
|
|
28
|
|
|
// Add custom columns to the classification index view. |
|
29
|
|
|
$this->crud->addColumn([ |
|
30
|
|
|
'name' => 'id', |
|
31
|
|
|
'type' => 'text', |
|
32
|
|
|
'label' => 'ID', |
|
33
|
|
|
]); |
|
34
|
|
|
|
|
35
|
|
|
$this->crud->addColumn([ |
|
36
|
|
|
'name' => 'key', |
|
37
|
|
|
'type' => 'text', |
|
38
|
|
|
'label' => 'Key', |
|
39
|
|
|
]); |
|
40
|
|
|
|
|
41
|
|
|
// Add custom fields to the create/update views. |
|
42
|
|
|
$this->crud->addField([ |
|
43
|
|
|
'name' => 'key', |
|
44
|
|
|
'type' => 'text', |
|
45
|
|
|
'label' => 'Key', |
|
46
|
|
|
]); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Action for creating a new classification in the database. |
|
51
|
|
|
* |
|
52
|
|
|
* @param \App\Http\Requests\ClassificationCrudRequest $request Incoming form request. |
|
53
|
|
|
* |
|
54
|
|
|
* @return \Illuminate\Http\RedirectResponse |
|
55
|
|
|
*/ |
|
56
|
|
|
public function store(StoreRequest $request) // phpcs:ignore |
|
|
|
|
|
|
57
|
|
|
{ |
|
58
|
|
|
return parent::storeCrud(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Action for updating an existing classification in the database. |
|
63
|
|
|
* |
|
64
|
|
|
* @param \App\Http\Requests\ClassificationCrudRequest $request Incoming form request. |
|
65
|
|
|
* |
|
66
|
|
|
* @return \Illuminate\Http\RedirectResponse |
|
67
|
|
|
*/ |
|
68
|
|
|
public function update(UpdateRequest $request) // phpcs:ignore |
|
|
|
|
|
|
69
|
|
|
{ |
|
70
|
|
|
return parent::updateCrud(); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.