Completed
Push — develop ( 517a16...15eb96 )
by Abdelrahman
08:48 queued 14s
created

AbstractController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Foundation\Http\Controllers;
6
7
use Illuminate\Routing\Controller;
8
use Illuminate\Support\Facades\Route;
9
use Rinvex\Fort\Traits\GetsMiddleware;
10
use Illuminate\Foundation\Bus\DispatchesJobs;
11
use Illuminate\Foundation\Validation\ValidatesRequests;
12
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
13
14
abstract class AbstractController extends Controller
15
{
16
    use GetsMiddleware;
17
    use DispatchesJobs;
18
    use ValidatesRequests;
19
    use AuthorizesRequests;
20
21
    /**
22
     * Whitelisted methods.
23
     * Array of whitelisted methods which do not need to go through middleware.
24
     *
25
     * @var array
26
     */
27
    protected $middlewareWhitelist = [];
28
29
    /**
30
     * The broker name.
31
     *
32
     * @var string
33
     */
34
    protected $broker;
35
36
    /**
37
     * Create a new authenticated controller instance.
38
     */
39
    public function __construct()
40
    {
41
        // Set accessarea to the global request parameter bag
42
        $accessArea = str_before(Route::currentRouteName(), '.');
43
        request()->request->add(['accessarea' => $accessArea]);
44
    }
45
46
    /**
47
     * Get the broker to be used.
48
     *
49
     * @return string
50
     */
51
    protected function getBroker()
52
    {
53
        return $this->broker;
54
    }
55
}
56