|
1
|
|
|
<?php namespace Arcanesoft\Auth\ViewComposers; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanesoft\Contracts\Auth\Models\Role; |
|
4
|
|
|
use Illuminate\Contracts\View\View; |
|
5
|
|
|
use Illuminate\Support\Collection; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class RolesComposer |
|
9
|
|
|
* |
|
10
|
|
|
* @package Arcanesoft\Auth\ViewComposers |
|
11
|
|
|
* @author ARCANEDEV <[email protected]> |
|
12
|
|
|
*/ |
|
13
|
|
|
class RolesComposer extends ViewComposer |
|
14
|
|
|
{ |
|
15
|
|
|
/* ----------------------------------------------------------------- |
|
16
|
|
|
| Properties |
|
17
|
|
|
| ----------------------------------------------------------------- |
|
18
|
|
|
*/ |
|
19
|
|
|
/** |
|
20
|
|
|
* The role model. |
|
21
|
|
|
* |
|
22
|
|
|
* @var \Arcanesoft\Contracts\Auth\Models\Role |
|
23
|
|
|
*/ |
|
24
|
|
|
private $role; |
|
25
|
|
|
|
|
26
|
|
|
/* ----------------------------------------------------------------- |
|
27
|
|
|
| Constructor |
|
28
|
|
|
| ----------------------------------------------------------------- |
|
29
|
|
|
*/ |
|
30
|
|
|
/** |
|
31
|
|
|
* RolesComposer constructor. |
|
32
|
|
|
* |
|
33
|
|
|
* @param \Arcanesoft\Contracts\Auth\Models\Role $role |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct(Role $role) |
|
36
|
|
|
{ |
|
37
|
|
|
$this->role = $role; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/* ----------------------------------------------------------------- |
|
41
|
|
|
| Main Methods |
|
42
|
|
|
| ----------------------------------------------------------------- |
|
43
|
|
|
*/ |
|
44
|
|
|
/** |
|
45
|
|
|
* Compose the view. |
|
46
|
|
|
* |
|
47
|
|
|
* @param \Illuminate\Contracts\View\View $view |
|
48
|
|
|
*/ |
|
49
|
|
|
public function composeFilters(View $view) |
|
50
|
|
|
{ |
|
51
|
|
|
$roles = $this->cacheResults('roles.filters', function () { |
|
52
|
|
|
return $this->role->has('users')->get(); |
|
|
|
|
|
|
53
|
|
|
}); |
|
54
|
|
|
|
|
55
|
|
|
$filters = new Collection; |
|
56
|
|
|
$filters->push(link_to_route('admin::auth.users.index', trans('core::generals.all'))); |
|
57
|
|
|
|
|
58
|
|
|
foreach ($roles as $role) { |
|
59
|
|
|
/** @var \Arcanesoft\Auth\Models\Role $role */ |
|
60
|
|
|
$filters->push(link_to_route('admin::auth.users.roles-filter.index', $role->name, [$role->hashed_id])); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
$view->with('rolesFilters', $filters); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.