|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Uccello\Core\Models\Module; |
|
4
|
|
|
|
|
5
|
|
|
if (!function_exists('uccello')) { |
|
6
|
|
|
/** |
|
7
|
|
|
* Return an instance of Uccello\Core\Helpers\Uccello |
|
8
|
|
|
* |
|
9
|
|
|
* @return void |
|
10
|
|
|
*/ |
|
11
|
|
|
function uccello() |
|
12
|
|
|
{ |
|
13
|
|
|
return app('uccello'); |
|
|
|
|
|
|
14
|
|
|
} |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
if (!function_exists('uctrans')) { |
|
18
|
|
|
/** |
|
19
|
|
|
* Retrieve prefix and translate the given message. If the default translation does not exist try to find a fallback one. |
|
20
|
|
|
* |
|
21
|
|
|
* @param string $key |
|
22
|
|
|
* @param Module|null $module |
|
23
|
|
|
* @param array $replace |
|
24
|
|
|
* @param string $locale |
|
25
|
|
|
* @return \Illuminate\Contracts\Translation\Translator|string|array|null |
|
26
|
|
|
* |
|
27
|
|
|
* @see Uccello\Core\Helpers\Uccello |
|
28
|
|
|
*/ |
|
29
|
|
|
function uctrans($key = null, ? Module $module = null, $replace = [ ], $locale = null) |
|
30
|
|
|
{ |
|
31
|
|
|
return app('uccello')->trans($key, $module, $replace, $locale); |
|
|
|
|
|
|
32
|
|
|
} |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
if (!function_exists('ucmodule')) { |
|
36
|
|
|
/** |
|
37
|
|
|
* Get a module instance by name or id |
|
38
|
|
|
* |
|
39
|
|
|
* @param string|int $name |
|
40
|
|
|
* @return Module|null |
|
41
|
|
|
*/ |
|
42
|
|
|
function ucmodule($nameOrId): ?Module |
|
43
|
|
|
{ |
|
44
|
|
|
return app('uccello')->getModule($nameOrId); |
|
|
|
|
|
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
if (!function_exists('ucroute')) { |
|
49
|
|
|
/** |
|
50
|
|
|
* Makes route automaticaly and add domain and module parameter. |
|
51
|
|
|
* |
|
52
|
|
|
* @param array|string $name |
|
53
|
|
|
* @param Domain|string|null $domain |
|
54
|
|
|
* @param Module|string|null $module |
|
55
|
|
|
* @param mixed $parameters |
|
56
|
|
|
* @param boolean $absolute |
|
57
|
|
|
* @return string |
|
58
|
|
|
*/ |
|
59
|
|
|
function ucroute($name, $domain = null, $module = null, $parameters = [ ], $absolute = true) : string |
|
60
|
|
|
{ |
|
61
|
|
|
return app('uccello')->route($name, $domain, $module, $parameters, $absolute); |
|
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
if (!function_exists('uclog')) { |
|
66
|
|
|
/** |
|
67
|
|
|
* Use Debugbar to log data. |
|
68
|
|
|
* |
|
69
|
|
|
* @param mixed $data |
|
70
|
|
|
* @return void |
|
71
|
|
|
*/ |
|
72
|
|
|
function uclog($data) |
|
73
|
|
|
{ |
|
74
|
|
|
\Debugbar::info($data); |
|
|
|
|
|
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
if (!function_exists('uitype')) { |
|
79
|
|
|
/** |
|
80
|
|
|
* Get an uitype instance by name or id |
|
81
|
|
|
* |
|
82
|
|
|
* @param string|int $nameOrId |
|
83
|
|
|
* @return Uitype|null |
|
|
|
|
|
|
84
|
|
|
*/ |
|
85
|
|
|
function uitype($nameOrId) |
|
86
|
|
|
{ |
|
87
|
|
|
return app('uccello')->getUitype($nameOrId); |
|
|
|
|
|
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
if (!function_exists('displaytype')) { |
|
92
|
|
|
/** |
|
93
|
|
|
* Get a display type instance by name or id |
|
94
|
|
|
* |
|
95
|
|
|
* @param string|int $nameOrId |
|
96
|
|
|
* @return Displaytype|null |
|
|
|
|
|
|
97
|
|
|
*/ |
|
98
|
|
|
function displaytype($nameOrId) |
|
99
|
|
|
{ |
|
100
|
|
|
return app('uccello')->getDisplaytype($nameOrId); |
|
|
|
|
|
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
if (!function_exists('capability')) { |
|
105
|
|
|
/** |
|
106
|
|
|
* Get a capability instance by name or id |
|
107
|
|
|
* |
|
108
|
|
|
* @param string|int $nameOrId |
|
109
|
|
|
* @return Capabillity|null |
|
|
|
|
|
|
110
|
|
|
*/ |
|
111
|
|
|
function capability($nameOrId) |
|
112
|
|
|
{ |
|
113
|
|
|
return app('uccello')->getCapability($nameOrId); |
|
|
|
|
|
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
if (!function_exists('ucasset')) { |
|
118
|
|
|
/** |
|
119
|
|
|
* Get complete path to asset |
|
120
|
|
|
* |
|
121
|
|
|
* @param string $path |
|
122
|
|
|
* @param string $package |
|
123
|
|
|
* @return void |
|
124
|
|
|
*/ |
|
125
|
|
|
function ucasset($path, $package = 'uccello/uccello') |
|
126
|
|
|
{ |
|
127
|
|
|
return asset("vendor/$package/$path"); |
|
|
|
|
|
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
if (!function_exists('ucattribute')) { |
|
132
|
|
|
/** |
|
133
|
|
|
* Returns a record attribute value. |
|
134
|
|
|
* It is able to follow a complex path according to models definition (e.g. 'domain.parent.name') |
|
135
|
|
|
* |
|
136
|
|
|
* @param Object $record |
|
137
|
|
|
* @param string $attribute |
|
138
|
|
|
* @return string|Object|Array|null |
|
139
|
|
|
*/ |
|
140
|
|
|
function ucattribute($record, $attribute) |
|
141
|
|
|
{ |
|
142
|
|
|
return app('uccello')->getRecordAttribute($record, $attribute); |
|
|
|
|
|
|
143
|
|
|
} |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
if (!function_exists('ucnotify')) { |
|
147
|
|
|
/** |
|
148
|
|
|
* Uses flash session to display a notification. |
|
149
|
|
|
* |
|
150
|
|
|
* @param string $message |
|
151
|
|
|
* @param string $type |
|
152
|
|
|
* @return void |
|
153
|
|
|
*/ |
|
154
|
|
|
function ucnotify($message, $type = 'info') { |
|
155
|
|
|
session()->flash('notification-'.$type, $message); |
|
156
|
|
|
} |
|
157
|
|
|
} |