|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Backpack\MenuCRUD\app\Http\Controllers\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Requests; |
|
6
|
|
|
use Backpack\CRUD\app\Http\Controllers\CrudController; |
|
7
|
|
|
// VALIDATION: change the requests to match your own file names if you need form validation |
|
8
|
|
|
use Backpack\CRUD\app\Http\Requests\CrudRequest as StoreRequest; |
|
9
|
|
|
use Backpack\CRUD\app\Http\Requests\CrudRequest as UpdateRequest; |
|
10
|
|
|
|
|
11
|
|
|
class MenuItemCrudController extends CrudController |
|
12
|
|
|
{ |
|
13
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation; |
|
14
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation; |
|
15
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation; |
|
16
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation; |
|
17
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\ReorderOperation; |
|
18
|
|
|
|
|
19
|
|
|
public function setup() |
|
20
|
|
|
{ |
|
21
|
|
|
$this->crud->setModel("Backpack\MenuCRUD\app\Models\MenuItem"); |
|
22
|
|
|
$this->crud->setRoute(config('backpack.base.route_prefix').'/menu-item'); |
|
23
|
|
|
$this->crud->setEntityNameStrings('menu item', 'menu items'); |
|
24
|
|
|
|
|
25
|
|
|
$this->crud->enableReorder('name', 3); |
|
26
|
|
|
|
|
27
|
|
|
$this->crud->operation('list', function () { |
|
|
|
|
|
|
28
|
|
|
$this->crud->addColumn([ |
|
29
|
|
|
'name' => 'name', |
|
30
|
|
|
'label' => 'Label', |
|
31
|
|
|
]); |
|
32
|
|
|
$this->crud->addColumn([ |
|
33
|
|
|
'label' => 'Parent', |
|
34
|
|
|
'type' => 'select', |
|
35
|
|
|
'name' => 'parent_id', |
|
36
|
|
|
'entity' => 'parent', |
|
37
|
|
|
'attribute' => 'name', |
|
38
|
|
|
'model' => "\Backpack\MenuCRUD\app\Models\MenuItem", |
|
39
|
|
|
]); |
|
40
|
|
|
}); |
|
41
|
|
|
|
|
42
|
|
|
$this->crud->operation(['create', 'update'], function () { |
|
|
|
|
|
|
43
|
|
|
$this->crud->addField([ |
|
44
|
|
|
'name' => 'name', |
|
45
|
|
|
'label' => 'Label', |
|
46
|
|
|
]); |
|
47
|
|
|
$this->crud->addField([ |
|
48
|
|
|
'label' => 'Parent', |
|
49
|
|
|
'type' => 'select', |
|
50
|
|
|
'name' => 'parent_id', |
|
51
|
|
|
'entity' => 'parent', |
|
52
|
|
|
'attribute' => 'name', |
|
53
|
|
|
'model' => "\Backpack\MenuCRUD\app\Models\MenuItem", |
|
54
|
|
|
]); |
|
55
|
|
|
$this->crud->addField([ |
|
56
|
|
|
'name' => 'type', |
|
57
|
|
|
'label' => 'Type', |
|
58
|
|
|
'type' => 'page_or_link', |
|
59
|
|
|
'page_model' => '\Backpack\PageManager\app\Models\Page', |
|
60
|
|
|
]); |
|
61
|
|
|
}); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function store(StoreRequest $request) |
|
|
|
|
|
|
65
|
|
|
{ |
|
66
|
|
|
return $this->storeEntry($request); |
|
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function update(UpdateRequest $request) |
|
|
|
|
|
|
70
|
|
|
{ |
|
71
|
|
|
return $this->updateEntry($request); |
|
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.