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
|
|
|
|