ApplicationController::update()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 14
nc 1
nop 1
dl 0
loc 20
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers\Settings;
4
5
use App\Http\Controllers\Controller;
6
use Brotzka\DotenvEditor\DotenvEditor;
7
use App\Http\Requests\Settings\ApplicationSettingsUpdateRequest;
8
9
/**
10
 * Class ApplicationController.
11
 */
12
class ApplicationController extends Controller
13
{
14
    /**
15
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
16
     */
17
    public function index()
18
    {
19
        return view('settings.application');
20
    }
21
22
    /**
23
     * @param ApplicationSettingsUpdateRequest $request
24
     * @return \Illuminate\Http\RedirectResponse
25
     * @throws \Brotzka\DotenvEditor\Exceptions\DotEnvException
26
     */
27
    public function update(ApplicationSettingsUpdateRequest $request)
28
    {
29
        $env = new DotenvEditor;
30
        $env->changeEnv([
31
            'APP_NAME' => '"'.$request->input('APP_NAME').'"',
32
            'APP_URL' => $request->input('APP_URL'),
33
            'APP_EMAIL' => $request->input('APP_EMAIL'),
34
            'APP_FROM' => '"'.$request->input('APP_FROM').'"',
35
            'APP_REGISTER' => $request->input('APP_REGISTER'),
36
            'APP_EDITOR' => $request->input('APP_EDITOR'),
37
            'NOTIFICATIONS' => $request->input('NOTIFICATIONS'),
38
            'APP_LOCALE' => $request->input('APP_LANGUAGE'),
39
        ]);
40
41
        notify()->flash(trans('general.woohoo'), 'success', [
0 ignored issues
show
Bug introduced by
It seems like trans('general.woohoo') can also be of type array; however, parameter $message of Codecourse\Notify\Notifier::flash() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

41
        notify()->flash(/** @scrutinizer ignore-type */ trans('general.woohoo'), 'success', [
Loading history...
42
            'timer' => 2000,
43
            'text' => trans('general.success.update'),
44
        ]);
45
46
        return redirect()->route('settings.application');
47
    }
48
}
49