1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Terranet\Administrator\Traits\Actions; |
4
|
|
|
|
5
|
|
|
use Illuminate\Database\Eloquent\Model as Eloquent; |
|
|
|
|
6
|
|
|
|
7
|
|
|
trait Skeleton |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @return string |
11
|
|
|
*/ |
12
|
|
|
public function type(): string |
13
|
|
|
{ |
14
|
|
|
return 'primary'; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Render action button. |
19
|
|
|
* |
20
|
|
|
* @param Eloquent $entity |
21
|
|
|
* @return string |
22
|
|
|
*/ |
23
|
|
|
public function render(Eloquent $entity = null) |
24
|
|
|
{ |
25
|
|
|
$action = app('scaffold.module')->url().'-'.$this->action($entity); |
|
|
|
|
26
|
|
|
$icon = ($i = $this->icon($entity)) ? "<i class=\"fa {$i}\"></i>" : ''; |
27
|
|
|
|
28
|
|
|
return |
29
|
|
|
<<<OUTPUT |
30
|
|
|
<a data-scaffold-action="{$action}" data-scaffold-key="{$this->entityKey($entity)}" href="{$this->route($entity)}" {$this->attributes($entity)}> |
|
|
|
|
31
|
|
|
{$icon}<span>{$this->name($entity)}</span> |
32
|
|
|
</a> |
33
|
|
|
OUTPUT; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Render action button. |
38
|
|
|
* |
39
|
|
|
* @param Eloquent $entity |
40
|
|
|
* @return string |
41
|
|
|
*/ |
42
|
|
|
public function renderBtn(Eloquent $entity = null) |
43
|
|
|
{ |
44
|
|
|
$action = app('scaffold.module')->url().'-'.$this->action($entity); |
|
|
|
|
45
|
|
|
$icon = ($i = $this->icon($entity)) ? "<i class=\"fa {$i}\"></i>" : ''; |
46
|
|
|
|
47
|
|
|
return |
48
|
|
|
<<<OUTPUT |
49
|
|
|
<a class="btn btn-{$this->type()}" data-scaffold-action="{$action}" data-scaffold-key="{$this->entityKey($entity)}" href="{$this->route($entity)}" {$this->attributes($entity)}> |
|
|
|
|
50
|
|
|
{$icon}<span>{$this->name($entity)}</span> |
51
|
|
|
</a> |
52
|
|
|
OUTPUT; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param Eloquent $entity |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
protected function action(Eloquent $entity = null) |
|
|
|
|
60
|
|
|
{ |
61
|
|
|
return snake_case(class_basename($this)); |
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Action name. |
66
|
|
|
* |
67
|
|
|
* @param Eloquent $entity |
68
|
|
|
* @return string |
69
|
|
|
*/ |
70
|
|
|
protected function name(Eloquent $entity = null) |
|
|
|
|
71
|
|
|
{ |
72
|
|
|
return app('translator')->has($key = $this->translationKey()) |
|
|
|
|
73
|
|
|
? trans($key) |
|
|
|
|
74
|
|
|
: title_case(str_replace('_', ' ', snake_case(class_basename($this)))); |
|
|
|
|
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param Eloquent $entity |
79
|
|
|
* @return string |
80
|
|
|
*/ |
81
|
|
|
protected function icon(Eloquent $entity = null) |
|
|
|
|
82
|
|
|
{ |
83
|
|
|
return 'fa-circle-thin'; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return string |
88
|
|
|
*/ |
89
|
|
|
protected function translationKey(): string |
90
|
|
|
{ |
91
|
|
|
$key = sprintf('administrator::actions.%s.%s', app('scaffold.module')->url(), snake_case(class_basename($this))); |
|
|
|
|
92
|
|
|
|
93
|
|
|
if (!app('translator')->has($key)) { |
94
|
|
|
$key = sprintf('administrator::actions.global.%s', snake_case(class_basename($this))); |
|
|
|
|
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
return $key; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param null $entity |
|
|
|
|
102
|
|
|
* @return string |
103
|
|
|
*/ |
104
|
|
|
protected function entityKey($entity = null): string |
105
|
|
|
{ |
106
|
|
|
return $entity ? $entity->getKey() : 'empty'; |
|
|
|
|
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths