RegisteredUserController::store()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 19
rs 9.9
1
<?php
2
3
namespace App\Http\Controllers\Auth;
4
5
use App\Http\Controllers\Controller;
6
use App\Models\User;
7
use Illuminate\Auth\Events\Registered;
8
use Illuminate\Http\RedirectResponse;
9
use Illuminate\Http\Request;
10
use Illuminate\Support\Facades\Auth;
11
use Illuminate\Support\Facades\Hash;
12
use Illuminate\Validation\Rules;
13
use Inertia\Inertia;
14
use Inertia\Response;
15
16
class RegisteredUserController extends Controller
17
{
18
    /**
19
     * Display the registration view.
20
     */
21
    public function create(): Response
22
    {
23
        return Inertia::render('Auth/Register');
24
    }
25
26
    /**
27
     * Handle an incoming registration request.
28
     *
29
     * @throws \Illuminate\Validation\ValidationException
30
     */
31
    public function store(Request $request): RedirectResponse
32
    {
33
        $request->validate([
0 ignored issues
show
Bug introduced by
The method validate() does not exist on Illuminate\Http\Request. ( Ignorable by Annotation )

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

33
        $request->/** @scrutinizer ignore-call */ 
34
                  validate([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34
            'name' => 'required|string|max:255',
35
            'email' => 'required|string|lowercase|email|max:255|unique:'.User::class,
36
            'password' => ['required', 'confirmed', Rules\Password::defaults()],
37
        ]);
38
39
        $user = User::create([
40
            'name' => $request->name,
0 ignored issues
show
Bug introduced by
The property name does not seem to exist on Illuminate\Http\Request.
Loading history...
41
            'email' => $request->email,
0 ignored issues
show
Bug introduced by
The property email does not seem to exist on Illuminate\Http\Request.
Loading history...
42
            'password' => Hash::make($request->password),
0 ignored issues
show
Bug introduced by
The property password does not seem to exist on Illuminate\Http\Request.
Loading history...
43
        ]);
44
45
        event(new Registered($user));
0 ignored issues
show
Bug introduced by
It seems like $user can also be of type Illuminate\Database\Eloq...gHasThroughRelationship; however, parameter $user of Illuminate\Auth\Events\Registered::__construct() does only seem to accept Illuminate\Contracts\Auth\Authenticatable, 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

45
        event(new Registered(/** @scrutinizer ignore-type */ $user));
Loading history...
46
47
        Auth::login($user);
0 ignored issues
show
Bug introduced by
It seems like $user can also be of type Illuminate\Database\Eloq...gHasThroughRelationship; however, parameter $user of Illuminate\Support\Facades\Auth::login() does only seem to accept Illuminate\Contracts\Auth\Authenticatable, 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

47
        Auth::login(/** @scrutinizer ignore-type */ $user);
Loading history...
48
49
        return redirect(route('dashboard', absolute: false));
50
    }
51
}
52