Completed
Push — master ( 8927df...f70445 )
by Abdelrahman
02:05
created

RegistrationController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 62
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A showRegisteration() 0 4 1
B processRegisteration() 0 31 2
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 Rinvex\Fort\Contracts\UserRepositoryContract;
19
use Rinvex\Fort\Http\Controllers\AbstractController;
20
use Rinvex\Fort\Http\Requests\Frontend\UserRegistrationRequest;
21
22
class RegistrationController extends AbstractController
23
{
24
    /**
25
     * Create a new registration controller instance.
26
     */
27
    public function __construct()
28
    {
29
        $this->middleware($this->getGuestMiddleware(), ['except' => $this->middlewareWhitelist]);
30
    }
31
32
    /**
33
     * Show the registration form.
34
     *
35
     * @param \Rinvex\Fort\Http\Requests\Frontend\UserRegistrationRequest $request
36
     *
37
     * @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...
38
     */
39
    public function showRegisteration(UserRegistrationRequest $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...
40
    {
41
        return view('rinvex/fort::frontend/authentication.register');
42
    }
43
44
    /**
45
     * Process the registration form.
46
     *
47
     * @param \Rinvex\Fort\Http\Requests\Frontend\UserRegistrationRequest $request
48
     * @param \Rinvex\Fort\Contracts\UserRepositoryContract               $userRepository
49
     *
50
     * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
51
     */
52
    public function processRegisteration(UserRegistrationRequest $request, UserRepositoryContract $userRepository)
53
    {
54
        // Prepare registration data
55
        $input  = $request->except(['_method', '_token']);
56
        $active = ['active' => ! config('rinvex.fort.registration.moderated')];
57
58
        // Fire the register start event
59
        event('rinvex.fort.register.start', [$input + $active]);
60
61
        $result = $userRepository->create($input + $active);
62
63
        // Fire the register success event
64
        event('rinvex.fort.register.success', [$result]);
65
66
        // Send verification if required
67
        if (config('rinvex.fort.emailverification.required')) {
68
            app('rinvex.fort.emailverification')->broker()->send(['email' => $input['email']]);
69
70
            // Registration completed, verification required
71
            return intend([
72
                'intended' => url('/'),
73
                'with'     => ['rinvex.fort.alert.success' => trans('rinvex/fort::frontend/messages.register.success_verify')],
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 127 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...
74
            ]);
75
        }
76
77
        // Registration completed successfully
78
        return intend([
79
            'intended' => route('rinvex.fort.frontend.auth.login'),
80
            'with'     => ['rinvex.fort.alert.success' => trans('rinvex/fort::frontend/messages.register.success')],
81
        ]);
82
    }
83
}
84