1
|
|
|
<?php namespace Arcanesoft\Auth\ViewComposers; |
2
|
|
|
|
3
|
|
|
use Arcanesoft\Contracts\Auth\Models\Permission; |
4
|
|
|
use Arcanesoft\Contracts\Auth\Models\PermissionsGroup; |
5
|
|
|
use Illuminate\Contracts\View\View; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class PermissionsGroupsComposer |
9
|
|
|
* |
10
|
|
|
* @package Arcanesoft\Auth\ViewComposers |
11
|
|
|
* @author ARCANEDEV <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
class PermissionsGroupsComposer extends ViewComposer |
14
|
|
|
{ |
15
|
|
|
/* ------------------------------------------------------------------------------------------------ |
16
|
|
|
| Main Functions |
17
|
|
|
| ------------------------------------------------------------------------------------------------ |
18
|
|
|
*/ |
19
|
|
|
/** |
20
|
|
|
* Compose the view. |
21
|
|
|
* |
22
|
|
|
* @param \Illuminate\Contracts\View\View $view |
23
|
|
|
*/ |
24
|
|
|
public function composeFilters(View $view) |
25
|
|
|
{ |
26
|
|
|
$filters = collect(); |
27
|
|
|
|
28
|
|
|
// Permission groups |
29
|
|
|
//---------------------------------- |
30
|
|
|
$groups = $this->cacheResults('permissions-groups.filters', function () { |
31
|
|
|
return PermissionsGroup::has('permissions')->get(); |
|
|
|
|
32
|
|
|
}); |
33
|
|
|
|
34
|
|
|
foreach ($groups as $group) { |
35
|
|
|
/** @var \Arcanesoft\Auth\Models\PermissionsGroup $group */ |
36
|
|
|
$filters->put($group->slug, link_to_route('auth::foundation.permissions.group', $group->name, [ |
37
|
|
|
$group->hashed_id |
38
|
|
|
])); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
// Custom Permission group |
42
|
|
|
//---------------------------------- |
43
|
|
|
if (Permission::where('group_id', 0)->count()) { |
|
|
|
|
44
|
|
|
$filters->put('custom', link_to_route('auth::foundation.permissions.group', 'Custom', [ |
45
|
|
|
hasher()->encode(0) |
46
|
|
|
])); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$view->with('groupFilters', $filters->toArray()); // TODO: return a collection instead of simple array |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
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.