1
|
|
|
<?php namespace Backpack\Settings\app\Http\Controllers; |
2
|
|
|
|
3
|
|
|
use Illuminate\Http\Request; |
4
|
|
|
use App\Http\Requests; |
5
|
|
|
use App\Http\Controllers\Controller; |
6
|
|
|
use Backpack\CRUD\app\Http\Controllers\CrudController; |
7
|
|
|
|
8
|
|
|
// VALIDATION |
9
|
|
|
use Backpack\Settings\app\Http\Requests\SettingRequest as StoreRequest; |
10
|
|
|
use Backpack\Settings\app\Http\Requests\SettingRequest as UpdateRequest; |
11
|
|
|
|
12
|
|
|
class SettingCrudController extends CrudController { |
13
|
|
|
|
14
|
|
|
public function __construct() { |
15
|
|
|
parent::__construct(); |
16
|
|
|
|
17
|
|
|
$this->crud->setModel("Backpack\Settings\app\Models\Setting"); |
|
|
|
|
18
|
|
|
$this->crud->setEntityNameStrings('setting', 'settings'); |
|
|
|
|
19
|
|
|
$this->crud->setRoute('admin/setting'); |
|
|
|
|
20
|
|
|
$this->crud->denyAccess(['create', 'delete']); |
|
|
|
|
21
|
|
|
$this->crud->setColumns(['name', 'value', 'description']); |
|
|
|
|
22
|
|
|
$this->crud->addField([ |
|
|
|
|
23
|
|
|
'name' => 'name', |
24
|
|
|
'label' => 'Name', |
25
|
|
|
'type' => 'text', |
26
|
|
|
'disabled' => 'disabled' |
27
|
|
|
]); |
28
|
|
|
$this->crud->addField([ |
|
|
|
|
29
|
|
|
'name' => 'value', |
30
|
|
|
'label' => 'Value', |
31
|
|
|
'type' => 'text' |
32
|
|
|
]); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Display all rows in the database for this entity. |
37
|
|
|
* This overwrites the default CrudController behaviour: |
38
|
|
|
* - instead of showing all entries, only show the "active" ones |
39
|
|
|
* |
40
|
|
|
* @return Response |
41
|
|
|
*/ |
42
|
|
|
public function index() |
43
|
|
|
{ |
44
|
|
|
// if view_table_permission is false, abort |
45
|
|
|
$this->crud->hasAccessOrFail('list'); |
|
|
|
|
46
|
|
|
$this->crud->addClause('where', 'active', 1); // <---- this is where it's different from CrudController::index() |
|
|
|
|
47
|
|
|
|
48
|
|
|
$this->data['entries'] = $this->crud->getEntries(); |
|
|
|
|
49
|
|
|
$this->data['crud'] = $this->crud; |
50
|
|
|
$this->data['title'] = ucfirst($this->crud->entity_name_plural); |
51
|
|
|
|
52
|
|
|
// load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package |
53
|
|
|
return view('crud::list', $this->data); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function store(StoreRequest $request) |
|
|
|
|
57
|
|
|
{ |
58
|
|
|
return parent::storeCrud(); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function update(UpdateRequest $request) |
|
|
|
|
62
|
|
|
{ |
63
|
|
|
return parent::updateCrud(); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.