Completed
Push — master ( 08375c...9f214f )
by Mohamed
11:05
created

SettingController::update()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 1
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
0 ignored issues
show
Bug introduced by
There is no parameter named $setting. Was it maybe removed?

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 $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
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