Completed
Push — master ( 03b333...573f2e )
by Abdelrahman
02:45
created

RegistrationController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
/*
4
 * NOTICE OF LICENSE
5
 *
6
 * Part of the Rinvex Fort Package.
7
 *
8
 * This source file is subject to The MIT License (MIT)
9
 * that is bundled with this package in the LICENSE file.
10
 *
11
 * Package: Rinvex Fort Package
12
 * License: The MIT License (MIT)
13
 * Link:    https://rinvex.com
14
 */
15
16
namespace Rinvex\Fort\Http\Controllers\Frontend;
17
18
use Illuminate\Support\Facades\Auth;
19
use Illuminate\Support\Facades\Lang;
20
use Rinvex\Fort\Guards\SessionGuard;
21
use Rinvex\Fort\Http\Requests\UserRegistration;
22
use Rinvex\Fort\Http\Controllers\AbstractController;
23
use Rinvex\Fort\Contracts\VerificationBrokerContract;
24
25
class RegistrationController extends AbstractController
26
{
27
    /**
28
     * Create a new authentication controller instance.
29
     *
30
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
31
     */
32
    public function __construct()
33
    {
34
        $this->middleware($this->getGuestMiddleware(), ['except' => $this->middlewareWhitelist]);
35
    }
36
37
    /**
38
     * Show the registration form.
39
     *
40
     * @param \Rinvex\Fort\Http\Requests\UserRegistration $request
41
     *
42
     * @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...
43
     */
44
    public function showRegisteration(UserRegistration $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
45
    {
46
        return view('rinvex.fort::authentication.register');
47
    }
48
49
    /**
50
     * Process the registration form.
51
     *
52
     * @param \Rinvex\Fort\Http\Requests\UserRegistration $request
53
     *
54
     * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
55
     */
56
    public function processRegisteration(UserRegistration $request)
57
    {
58
        $result = Auth::guard($this->getGuard())->register($request->except('_token'));
59
60
        switch ($result) {
61
62
            // Registration completed, verification required
63
            case VerificationBrokerContract::LINK_SENT:
64
                return intend([
65
                    'home' => true,
66
                    'with' => ['rinvex.fort.alert.success' => Lang::get('rinvex.fort::message.register.success_verify')],
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 121 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...
67
                ]);
68
69
            // Registration completed successfully
70
            case SessionGuard::AUTH_REGISTERED:
71
            default:
72
                return intend([
73
                    'route' => 'rinvex.fort.auth.login',
74
                    'with'  => ['rinvex.fort.alert.success' => Lang::get($result)],
75
                ]);
76
77
        }
78
    }
79
}
80