1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Larrock\Core\Traits; |
4
|
|
|
|
5
|
|
|
trait ShareMethods |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Расшаривание переменных в шаблон, указывающих на использование методов управления контентом |
9
|
|
|
* @return array |
10
|
|
|
*/ |
11
|
|
|
public function shareMethods() |
12
|
|
|
{ |
13
|
|
|
$allowed = []; |
14
|
|
|
if (method_exists($this, 'create')) { |
15
|
|
|
\View::share('allowCreate', true); |
|
|
|
|
16
|
|
|
$allowed[] = 'allowCreate'; |
17
|
|
|
} |
18
|
|
|
if (method_exists($this, 'index')) { |
19
|
|
|
\View::share('allowIndex', true); |
20
|
|
|
$allowed[] = 'allowIndex'; |
21
|
|
|
} |
22
|
|
|
if (method_exists($this, 'store')) { |
23
|
|
|
\View::share('allowStore', true); |
24
|
|
|
$allowed[] = 'allowStore'; |
25
|
|
|
} |
26
|
|
|
if (method_exists($this, 'destroy')) { |
27
|
|
|
\View::share('allowDestroy', true); |
28
|
|
|
$allowed[] = 'allowDestroy'; |
29
|
|
|
} |
30
|
|
|
if (method_exists($this, 'edit')) { |
31
|
|
|
\View::share('allowEdit', true); |
32
|
|
|
$allowed[] = 'allowEdit'; |
33
|
|
|
} |
34
|
|
|
if (method_exists($this, 'update')) { |
35
|
|
|
\View::share('allowUpdate', true); |
36
|
|
|
$allowed[] = 'allowUpdate'; |
37
|
|
|
} |
38
|
|
|
if (method_exists($this, 'show')) { |
39
|
|
|
\View::share('allowShow', true); |
40
|
|
|
$allowed[] = 'allowShow'; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
return $allowed; |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|