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