Completed
Push — develop ( ad6f8c...e0a689 )
by Abdelrahman
02:06
created

AccountSettingsController::update()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 3
eloc 8
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Fort\Http\Controllers\Frontend;
6
7
use Illuminate\Http\Request;
8
use Cortex\Fort\Http\Requests\Frontend\AccountSettingsRequest;
9
use Cortex\Foundation\Http\Controllers\AuthenticatedController;
10
11
class AccountSettingsController extends AuthenticatedController
12
{
13
    /**
14
     * Show the account update form.
15
     *
16
     * @param \Illuminate\Http\Request $request
17
     *
18
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\View\View|\I...\Contracts\View\Factory?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
19
     */
20
    public function edit(Request $request)
21
    {
22
        $countries = countries();
23
        $languages = collect(languages())->pluck('name', 'iso_639_1');
24
        $twoFactor = $request->user($this->getGuard())->getTwoFactor();
25
26
        return view('cortex/fort::frontend.account.settings', compact('twoFactor', 'countries', 'languages'));
27
    }
28
29
    /**
30
     * Process the account update form.
31
     *
32
     * @param \Cortex\Fort\Http\Requests\Frontend\AccountSettingsRequest $request
33
     *
34
     * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
35
     */
36
    public function update(AccountSettingsRequest $request)
37
    {
38
        $input = $request->all();
39
        $currentUser = $request->user($this->getGuard());
40
41
        // Update profile
42
        $currentUser->fill($input)->save();
43
44
        return intend([
45
            'back' => true,
46
            'with' => ['success' => trans('cortex/fort::messages.account.'.(isset($input['email_verified']) ? 'reverify' : 'updated'))]
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 135 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
47
                      + (isset($input['two_factor']) ? ['warning' => trans('cortex/fort::messages.verification.twofactor.phone.auto_disabled')] : []),
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 150 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
48
        ]);
49
    }
50
}
51