Completed
Pull Request — master (#2)
by ARCANEDEV
03:07
created

PermissionsComposer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 46
ccs 0
cts 14
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A composeRolePermissions() 0 11 1
1
<?php namespace Arcanesoft\Auth\ViewComposers;
2
3
use Arcanesoft\Auth\Bases\ViewComposer;
4
use Arcanesoft\Auth\Models\Permission;
5
use Illuminate\Contracts\View\View;
6
7
/**
8
 * Class     PermissionsComposer
9
 *
10
 * @package  Arcanesoft\Auth\ViewComposers
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class PermissionsComposer extends ViewComposer
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Properties
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    /**
20
     * @var \Arcanesoft\Auth\Models\Permission
21
     */
22
    protected $permissions;
23
24
    /* ------------------------------------------------------------------------------------------------
25
     |  Constructor
26
     | ------------------------------------------------------------------------------------------------
27
     */
28
    /**
29
     * PermissionsComposer constructor.
30
     *
31
     * @param Permission $permissions
32
     */
33
    public function __construct(Permission $permissions)
34
    {
35
        $this->permissions = $permissions;
36
    }
37
38
    /* ------------------------------------------------------------------------------------------------
39
     |  Main Functions
40
     | ------------------------------------------------------------------------------------------------
41
     */
42
    /**
43
     * Compose the view.
44
     *
45
     * @param  \Illuminate\Contracts\View\View  $view
46
     */
47
    public function composeRolePermissions(View $view)
48
    {
49
        $permissions = $this->cacheResults('auth-permissions-form', function () {
50
            return $this->permissions
51
                ->with('group')
52
                ->orderBy('group_id', 'desc')
53
                ->get();
54
        });
55
56
        $view->with('permissions', $permissions);
57
    }
58
}
59