|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Microboard\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Auth\Access\AuthorizationException; |
|
6
|
|
|
use Microboard\Http\Requests\Setting\UpdateFormRequest; |
|
7
|
|
|
use Microboard\Http\Requests\Setting\StoreFormRequest; |
|
8
|
|
|
use Illuminate\Http\RedirectResponse; |
|
9
|
|
|
use Microboard\Models\Setting; |
|
10
|
|
|
use Illuminate\View\View; |
|
11
|
|
|
|
|
12
|
|
|
class SettingController extends Controller |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* Display a listing of the resource. |
|
16
|
|
|
* |
|
17
|
|
|
* @return View |
|
18
|
|
|
* @throws AuthorizationException |
|
19
|
|
|
*/ |
|
20
|
|
|
public function index() |
|
21
|
|
|
{ |
|
22
|
|
|
$this->authorize('viewAny', new Setting); |
|
23
|
|
|
return view('microboard::settings.index'); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Store a newly created resource in storage. |
|
28
|
|
|
* |
|
29
|
|
|
* @param StoreFormRequest $request |
|
30
|
|
|
* @return RedirectResponse |
|
31
|
|
|
* @throws AuthorizationException |
|
32
|
|
|
*/ |
|
33
|
|
|
public function store(StoreFormRequest $request) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->authorize('create', new Setting); |
|
36
|
|
|
Setting::create($request->validated()); |
|
37
|
|
|
return redirect()->route('microboard.settings.index'); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Update the specified resource in storage. |
|
42
|
|
|
* |
|
43
|
|
|
* @param UpdateFormRequest $request |
|
44
|
|
|
* @param Setting $setting |
|
|
|
|
|
|
45
|
|
|
* @return RedirectResponse |
|
46
|
|
|
* @throws AuthorizationException |
|
47
|
|
|
*/ |
|
48
|
|
|
public function update(UpdateFormRequest $request) |
|
49
|
|
|
{ |
|
50
|
|
|
$this->authorize('update', new Setting); |
|
51
|
|
|
foreach ($request->get('value') as $id => $value) { |
|
52
|
|
|
Setting::find($id)->update([ |
|
53
|
|
|
'value' => $value |
|
54
|
|
|
]); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
return redirect()->route('microboard.settings.index'); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.