1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
if (! function_exists('datatables')) { |
4
|
|
|
/** |
5
|
|
|
* Get datatables instance. |
6
|
|
|
* |
7
|
|
|
* @return \Yajra\Datatables\Datatables |
8
|
|
|
*/ |
9
|
|
|
function datatables() |
10
|
|
|
{ |
11
|
|
|
return app('datatables'); |
12
|
|
|
} |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
if (! function_exists('dt_render')) { |
16
|
|
|
/** |
17
|
|
|
* Render a view. |
18
|
|
|
* |
19
|
|
|
* @param string $view |
20
|
|
|
* @param array $data |
21
|
|
|
* @return string |
22
|
|
|
*/ |
23
|
|
|
function dt_render($view, $data = []) |
24
|
|
|
{ |
25
|
|
|
return view($view, $data)->render(); |
26
|
|
|
} |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
if (! function_exists('dt_label')) { |
30
|
|
|
/** |
31
|
|
|
* Display a label view. |
32
|
|
|
* |
33
|
|
|
* @param string $label |
34
|
|
|
* @param string $type |
35
|
|
|
* @return string |
36
|
|
|
*/ |
37
|
|
|
function dt_label($label, $type = 'info') |
38
|
|
|
{ |
39
|
|
|
return dt_render('datatables::label', compact('label', 'type')); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
if (! function_exists('dt_badge')) { |
44
|
|
|
/** |
45
|
|
|
* Display a badge view. |
46
|
|
|
* |
47
|
|
|
* @param string $label |
48
|
|
|
* @param string $type |
49
|
|
|
* @return string |
50
|
|
|
*/ |
51
|
|
|
function dt_badge($label, $type = 'info') |
52
|
|
|
{ |
53
|
|
|
return dt_render('datatables::badge', compact('label', 'type')); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
if (! function_exists('dt_check')) { |
58
|
|
|
/** |
59
|
|
|
* Display a checkbox view. |
60
|
|
|
* |
61
|
|
|
* @param bool $checked |
62
|
|
|
* @return string |
63
|
|
|
*/ |
64
|
|
|
function dt_check($checked = true) |
65
|
|
|
{ |
66
|
|
|
return dt_render('datatables::check', compact('checked')); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
if (! function_exists('admin_prefix')) { |
71
|
|
|
/** |
72
|
|
|
* Display a checkbox view. |
73
|
|
|
* |
74
|
|
|
* @param bool $checked |
|
|
|
|
75
|
|
|
* @return string |
76
|
|
|
*/ |
77
|
|
|
function admin_prefix() |
78
|
|
|
{ |
79
|
|
|
return config('site.admin_prefix', 'administrator'); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
if (! function_exists('current_user')) { |
84
|
|
|
/** |
85
|
|
|
* Get current user instance. |
86
|
|
|
* |
87
|
|
|
* @param string|null $guard |
88
|
|
|
* @return \App\User|\Illuminate\Contracts\Auth\Authenticatable |
89
|
|
|
*/ |
90
|
|
|
function current_user($guard = null) |
91
|
|
|
{ |
92
|
|
|
if ($user = auth($guard)->user()) { |
93
|
|
|
return $user; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
return new Yajra\CMS\Entities\Guest; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
if (! function_exists('file_can_have_thumbnail')) { |
101
|
|
|
/** |
102
|
|
|
* Check if file is an image and can have thumbnail. |
103
|
|
|
* |
104
|
|
|
* @param string $file |
105
|
|
|
* @return bool |
106
|
|
|
*/ |
107
|
|
|
function file_can_have_thumbnail($file) |
108
|
|
|
{ |
109
|
|
|
return @exif_imagetype(substr($file, 7)); |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
if (! function_exists('html')) { |
114
|
|
|
/** |
115
|
|
|
* Get html builder instance. |
116
|
|
|
* |
117
|
|
|
* @return \Collective\Html\HtmlBuilder |
118
|
|
|
*/ |
119
|
|
|
function html() |
120
|
|
|
{ |
121
|
|
|
return app('html'); |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
if (! function_exists('form')) { |
126
|
|
|
/** |
127
|
|
|
* Get html builder instance. |
128
|
|
|
* |
129
|
|
|
* @return \Collective\Html\FormBuilder |
130
|
|
|
*/ |
131
|
|
|
function form() |
132
|
|
|
{ |
133
|
|
|
return app('form'); |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
if (! function_exists('bytesToHuman')) { |
138
|
|
|
/** |
139
|
|
|
* Convert bytes to a human readable presentation. |
140
|
|
|
* |
141
|
|
|
* @param int $bytes |
142
|
|
|
* @return string |
143
|
|
|
*/ |
144
|
|
|
function bytesToHuman($bytes) |
145
|
|
|
{ |
146
|
|
|
$units = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB']; |
147
|
|
|
|
148
|
|
|
for ($i = 0; $bytes > 1024; $i++) { |
149
|
|
|
$bytes /= 1024; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
return round($bytes, 2) . ' ' . $units[$i]; |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
if (! function_exists('file_ext_to_icon')) { |
157
|
|
|
/** |
158
|
|
|
* Get font-awesome icon by file ext. |
159
|
|
|
* |
160
|
|
|
* @param string $ext |
161
|
|
|
* @return string |
162
|
|
|
*/ |
163
|
|
|
function file_ext_to_icon($ext) |
164
|
|
|
{ |
165
|
|
|
$icons = [ |
166
|
|
|
'pdf' => 'fa-file-pdf-o', |
167
|
|
|
'doc' => 'fa-file-word-o', |
168
|
|
|
'docx' => 'fa-file-word-o', |
169
|
|
|
'ppt' => 'fa-file-powerpoint-o', |
170
|
|
|
'pptx' => 'fa-file-powerpoint-o', |
171
|
|
|
'xls' => 'fa-file-excel-o', |
172
|
|
|
'xlsx' => 'fa-file-excel-o', |
173
|
|
|
'csv' => 'fa-file-excel-o', |
174
|
|
|
'zip' => 'fa-file-archive-o', |
175
|
|
|
'tar' => 'fa-file-archive-o', |
176
|
|
|
'gz' => 'fa-file-archive-o', |
177
|
|
|
'rar' => 'fa-file-archive-o', |
178
|
|
|
'audio' => 'fa-file-audio-o', |
179
|
|
|
'mp3' => 'fa-file-audio-o', |
180
|
|
|
'wav' => 'fa-file-audio-o', |
181
|
|
|
'txt' => 'fa-file-code-o', |
182
|
|
|
'html' => 'fa-file-code-o', |
183
|
|
|
'php' => 'fa-file-code-o', |
184
|
|
|
'jpg' => 'fa-file-image-o', |
185
|
|
|
'jpeg' => 'fa-file-image-o', |
186
|
|
|
'png' => 'fa-file-image-o', |
187
|
|
|
'gif' => 'fa-file-image-o', |
188
|
|
|
'bmp' => 'fa-file-image-o', |
189
|
|
|
'tiff' => 'fa-file-image-o', |
190
|
|
|
'mov' => 'fa-file-movie-o', |
191
|
|
|
'mp4' => 'fa-file-movie-o', |
192
|
|
|
'avi' => 'fa-file-movie-o', |
193
|
|
|
]; |
194
|
|
|
|
195
|
|
|
if (in_array($ext, array_keys($icons))) { |
196
|
|
|
return $icons[$ext]; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
return 'fa-file-o'; |
200
|
|
|
} |
201
|
|
|
} |
202
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.