@@ -4,14 +4,14 @@ discard block |
||
4 | 4 | use Illuminate\Support\Str; |
5 | 5 | use Pratiksh\Adminetic\Models\Admin\Setting; |
6 | 6 | |
7 | -if (! function_exists('spa')) { |
|
7 | +if (!function_exists('spa')) { |
|
8 | 8 | function spa() |
9 | 9 | { |
10 | 10 | return setting('spa', config('adminetic.spa', true)); |
11 | 11 | } |
12 | 12 | } |
13 | 13 | |
14 | -if (! function_exists('getClassesList')) { |
|
14 | +if (!function_exists('getClassesList')) { |
|
15 | 15 | function getClassesList($dir) |
16 | 16 | { |
17 | 17 | $classes = \File::allFiles($dir); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | return $classes; |
27 | 27 | } |
28 | 28 | } |
29 | -if (! function_exists('getAllModelNames')) { |
|
29 | +if (!function_exists('getAllModelNames')) { |
|
30 | 30 | function getAllModelNames($dir) |
31 | 31 | { |
32 | 32 | $modelNames = []; |
@@ -40,42 +40,42 @@ discard block |
||
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | -if (! function_exists('validImageFolder')) { |
|
43 | +if (!function_exists('validImageFolder')) { |
|
44 | 44 | function validImageFolder($name, $default = 'default') |
45 | 45 | { |
46 | 46 | return strtolower(str_replace([' ', '-', '$', '<', '>', '&', '{', $closing_token, '*', '\\', '/', ':', '.', ';', ',', "'", '"'], '_', $name ?? trim($default))); |
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | -if (! function_exists('getImagePlaceholder')) { |
|
50 | +if (!function_exists('getImagePlaceholder')) { |
|
51 | 51 | function getImagePlaceholder() |
52 | 52 | { |
53 | 53 | return asset('adminetic/static/placeholder.png'); |
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | -if (! function_exists('getVerticalImagePlaceholder')) { |
|
57 | +if (!function_exists('getVerticalImagePlaceholder')) { |
|
58 | 58 | function getVerticalImagePlaceholder() |
59 | 59 | { |
60 | 60 | return asset('adminetic/static/vertical_placeholder.jpg'); |
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | -if (! function_exists('getSliderPlaceholder')) { |
|
64 | +if (!function_exists('getSliderPlaceholder')) { |
|
65 | 65 | function getSliderPlaceholder() |
66 | 66 | { |
67 | 67 | return asset('adminetic/static/slider.jpg'); |
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | -if (! function_exists('getFoodImagePlaceholder')) { |
|
71 | +if (!function_exists('getFoodImagePlaceholder')) { |
|
72 | 72 | function getFoodImagePlaceholder() |
73 | 73 | { |
74 | 74 | return asset('adminetic/static/food_placeholder.jpg'); |
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | -if (! function_exists('getProfilePlaceholder')) { |
|
78 | +if (!function_exists('getProfilePlaceholder')) { |
|
79 | 79 | function getProfilePlaceholder($p = null) |
80 | 80 | { |
81 | 81 | $profile = $p ?? Auth::user()->profile ?? Auth::user()->profile()->create(); |
@@ -84,91 +84,91 @@ discard block |
||
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | -if (! function_exists('title')) { |
|
87 | +if (!function_exists('title')) { |
|
88 | 88 | function title() |
89 | 89 | { |
90 | 90 | return setting('title', config('adminetic.name', 'Adminetic')); |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | -if (! function_exists('description')) { |
|
94 | +if (!function_exists('description')) { |
|
95 | 95 | function description($default = null) |
96 | 96 | { |
97 | 97 | return setting('description', config('adminetic.description', $default ?? 'Adminetic Admin Panel')); |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | -if (! function_exists('keywords')) { |
|
101 | +if (!function_exists('keywords')) { |
|
102 | 102 | function keywords() |
103 | 103 | { |
104 | 104 | return setting('keywords', config('adminetic.keywords', 'adminetic admin panel, adminetic, pratik shrestha, doctype innovations')); |
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | -if (! function_exists('loader_enabled')) { |
|
108 | +if (!function_exists('loader_enabled')) { |
|
109 | 109 | function loader_enabled() |
110 | 110 | { |
111 | 111 | return setting('loader_enabled', config('adminetic.loader_enabled', true)); |
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | -if (! function_exists('favicon')) { |
|
115 | +if (!function_exists('favicon')) { |
|
116 | 116 | function favicon() |
117 | 117 | { |
118 | - return getImg(! is_null(setting('favicon')) ? setting('favicon') : 'adminetic/static/favicon.png', 'adminetic/static/favicon.png'); |
|
118 | + return getImg(!is_null(setting('favicon')) ? setting('favicon') : 'adminetic/static/favicon.png', 'adminetic/static/favicon.png'); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | -if (! function_exists('logo')) { |
|
122 | +if (!function_exists('logo')) { |
|
123 | 123 | function logo() |
124 | 124 | { |
125 | - return getImg(! is_null(setting('logo')) ? setting('logo') : 'adminetic/static/logo.png', 'adminetic/static/logo.png'); |
|
125 | + return getImg(!is_null(setting('logo')) ? setting('logo') : 'adminetic/static/logo.png', 'adminetic/static/logo.png'); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | -if (! function_exists('dark_logo')) { |
|
129 | +if (!function_exists('dark_logo')) { |
|
130 | 130 | function dark_logo() |
131 | 131 | { |
132 | - return getImg(! is_null(setting('dark_logo')) ? setting('dark_logo') : 'adminetic/static/dark_logo.png', 'adminetic/static/dark_logo.png'); |
|
132 | + return getImg(!is_null(setting('dark_logo')) ? setting('dark_logo') : 'adminetic/static/dark_logo.png', 'adminetic/static/dark_logo.png'); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | -if (! function_exists('logoBanner')) { |
|
136 | +if (!function_exists('logoBanner')) { |
|
137 | 137 | function logoBanner() |
138 | 138 | { |
139 | - return getImg(! is_null(setting('logo_banner')) ? setting('logo_banner') : 'adminetic/static/logo_banner.png', 'adminetic/static/logo_banner.png'); |
|
139 | + return getImg(!is_null(setting('logo_banner')) ? setting('logo_banner') : 'adminetic/static/logo_banner.png', 'adminetic/static/logo_banner.png'); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | -if (! function_exists('login_register_bg_image')) { |
|
143 | +if (!function_exists('login_register_bg_image')) { |
|
144 | 144 | function login_register_bg_image() |
145 | 145 | { |
146 | - return getImg(! is_null(setting('login_register_bg_image')) ? setting('login_register_bg_image') : 'adminetic/static/login_register_bg_img.jpg', 'adminetic/static/login_register_bg_img.jpg'); |
|
146 | + return getImg(!is_null(setting('login_register_bg_image')) ? setting('login_register_bg_image') : 'adminetic/static/login_register_bg_img.jpg', 'adminetic/static/login_register_bg_img.jpg'); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | -if (! function_exists('getLazyLoadImg')) { |
|
150 | +if (!function_exists('getLazyLoadImg')) { |
|
151 | 151 | function getLazyLoadImg() |
152 | 152 | { |
153 | 153 | return asset('adminetic/static/loader.svg'); |
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | -if (! function_exists('random_color_part')) { |
|
157 | +if (!function_exists('random_color_part')) { |
|
158 | 158 | function random_color_part() |
159 | 159 | { |
160 | 160 | return str_pad(dechex(mt_rand(0, 255)), 2, '0', STR_PAD_LEFT); |
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | -if (! function_exists('random_color')) { |
|
164 | +if (!function_exists('random_color')) { |
|
165 | 165 | function random_color() |
166 | 166 | { |
167 | 167 | return random_color_part().random_color_part().random_color_part(); |
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | -if (! function_exists('setting')) { |
|
171 | +if (!function_exists('setting')) { |
|
172 | 172 | function setting($setting_name, $default = null) |
173 | 173 | { |
174 | 174 | $valid_setting_name = strtolower(str_replace(' ', '_', $setting_name)); |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
181 | -if (! function_exists('preference')) { |
|
181 | +if (!function_exists('preference')) { |
|
182 | 182 | function preference($preference_name, bool $default = null) |
183 | 183 | { |
184 | 184 | $valid_preference_name = strtolower(str_replace(' ', '_', $preference_name)); |
@@ -192,39 +192,39 @@ discard block |
||
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | -if (! function_exists('deleteImage')) { |
|
195 | +if (!function_exists('deleteImage')) { |
|
196 | 196 | function deleteImage($image) |
197 | 197 | { |
198 | 198 | $image ? (\Illuminate\Support\Facades\File::exists(public_path('storage/'.$image)) ? \Illuminate\Support\Facades\File::delete(public_path('storage/'.$image)) : '') : ''; |
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | -if (! function_exists('api_paginate_limit')) { |
|
202 | +if (!function_exists('api_paginate_limit')) { |
|
203 | 203 | function api_paginate_limit($default = null) |
204 | 204 | { |
205 | 205 | return setting('api_paginate_limit', $default ?? config('adminetic.api_paginate_limit', 10)); |
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
209 | -if (! function_exists('api_collection_return_paginate')) { |
|
209 | +if (!function_exists('api_collection_return_paginate')) { |
|
210 | 210 | function api_collection_return_paginate() |
211 | 211 | { |
212 | 212 | return setting('api_collection_return_paginate', config('adminetic.api_collection_return_paginate', true)); |
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
216 | -if (! function_exists('darkMode')) { |
|
216 | +if (!function_exists('darkMode')) { |
|
217 | 217 | function darkMode() |
218 | 218 | { |
219 | 219 | return setting('dark_mode', config('adminetic.dark_mode', false)); |
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | -if (! function_exists('getCondition')) { |
|
223 | +if (!function_exists('getCondition')) { |
|
224 | 224 | function getCondition($conditions) |
225 | 225 | { |
226 | 226 | $result = null; |
227 | - if (! isset($conditions)) { |
|
227 | + if (!isset($conditions)) { |
|
228 | 228 | return false; |
229 | 229 | } |
230 | 230 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | -if (! function_exists('getImg')) { |
|
253 | +if (!function_exists('getImg')) { |
|
254 | 254 | function getImg($img, $default) |
255 | 255 | { |
256 | 256 | if (isset($img)) { |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
270 | -if (! function_exists('putContentToClassFunction')) { |
|
270 | +if (!function_exists('putContentToClassFunction')) { |
|
271 | 271 | function putContentToClassFunction($file, $function_name, $data, $closing_token = '}') |
272 | 272 | { |
273 | 273 | $data = $data."\n"; |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | } |
303 | 303 | } |
304 | 304 | |
305 | -if (! function_exists('checkIfFieldIsRequired')) { |
|
305 | +if (!function_exists('checkIfFieldIsRequired')) { |
|
306 | 306 | function checkIfFieldIsRequired($table_name, $field) |
307 | 307 | { |
308 | 308 | $isNullable = null; |
@@ -319,11 +319,11 @@ discard block |
||
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
322 | -if (! function_exists('label')) { |
|
322 | +if (!function_exists('label')) { |
|
323 | 323 | function label($table, $field, $default_label = null) |
324 | 324 | { |
325 | 325 | $display_name = $default_label ?? Str::ucfirst(str_replace('_', ' ', $field)); |
326 | - if (! checkIfFieldIsRequired($table, $field)) { |
|
326 | + if (!checkIfFieldIsRequired($table, $field)) { |
|
327 | 327 | // do something if phone_number is nullable |
328 | 328 | echo "{$display_name} <span class='text-danger'>*</span>"; |
329 | 329 | } else { |
@@ -332,12 +332,12 @@ discard block |
||
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
335 | -if (! function_exists('role_theme')) { |
|
335 | +if (!function_exists('role_theme')) { |
|
336 | 336 | function role_theme() |
337 | 337 | { |
338 | 338 | $role = auth()->check() ? auth()->user()->roles->first()->name : null; |
339 | 339 | $role_theme = config('adminetic.role_theme', null); |
340 | - if (! is_null($role_theme)) { |
|
340 | + if (!is_null($role_theme)) { |
|
341 | 341 | return isset($role_theme[$role]) ? $role_theme[$role] : 'compact-sidebar'; |
342 | 342 | } |
343 | 343 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | } |
346 | 346 | } |
347 | 347 | |
348 | -if (! function_exists('setEnvValue')) { |
|
348 | +if (!function_exists('setEnvValue')) { |
|
349 | 349 | function setEnvValue(array $values) |
350 | 350 | { |
351 | 351 | $envFile = app()->environmentFilePath(); |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | $oldLine = substr($str, $keyPosition, $endOfLinePosition - $keyPosition); |
360 | 360 | |
361 | 361 | // If key does not exist, add it |
362 | - if (! $keyPosition || ! $endOfLinePosition || ! $oldLine) { |
|
362 | + if (!$keyPosition || !$endOfLinePosition || !$oldLine) { |
|
363 | 363 | $str .= "{$envKey}={$envValue}\n"; |
364 | 364 | } else { |
365 | 365 | $str = str_replace($oldLine, "{$envKey}={$envValue}", $str); |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | } |
369 | 369 | |
370 | 370 | $str = substr($str, 0, -1); |
371 | - if (! file_put_contents($envFile, $str)) { |
|
371 | + if (!file_put_contents($envFile, $str)) { |
|
372 | 372 | return false; |
373 | 373 | } |
374 | 374 |