@@ -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,35 +40,35 @@ 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([' ', '-', '$', '<', '>', '&', '{', '*', '\\', '/', ':', '.', ';', ',', "'", '"'], '_', $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(config('adminetic.default_image_placeholder', '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(config('adminetic.vertical_image_placeholder', '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(config('adminetic.slider_placeholder', 'adminetic/static/slider.jpg')); |
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | -if (! function_exists('getProfilePlaceholder')) { |
|
71 | +if (!function_exists('getProfilePlaceholder')) { |
|
72 | 72 | function getProfilePlaceholder($p = null) |
73 | 73 | { |
74 | 74 | $profile = $p ?? Auth::user()->profile ?? Auth::user()->profile()->create(); |
@@ -77,91 +77,91 @@ discard block |
||
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | -if (! function_exists('title')) { |
|
80 | +if (!function_exists('title')) { |
|
81 | 81 | function title() |
82 | 82 | { |
83 | 83 | return setting('title', config('adminetic.name', 'Adminetic')); |
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | -if (! function_exists('description')) { |
|
87 | +if (!function_exists('description')) { |
|
88 | 88 | function description($default = null) |
89 | 89 | { |
90 | 90 | return setting('description', config('adminetic.description', $default ?? 'Adminetic Admin Panel')); |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | -if (! function_exists('keywords')) { |
|
94 | +if (!function_exists('keywords')) { |
|
95 | 95 | function keywords() |
96 | 96 | { |
97 | 97 | return setting('keywords', config('adminetic.keywords', 'adminetic admin panel, adminetic, pratik shrestha, doctype innovations')); |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | -if (! function_exists('loader_enabled')) { |
|
101 | +if (!function_exists('loader_enabled')) { |
|
102 | 102 | function loader_enabled() |
103 | 103 | { |
104 | 104 | return setting('loader_enabled', config('adminetic.loader_enabled', true)); |
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | -if (! function_exists('favicon')) { |
|
108 | +if (!function_exists('favicon')) { |
|
109 | 109 | function favicon() |
110 | 110 | { |
111 | - return getImg(! is_null(setting('favicon')) ? setting('favicon', config('adminetic.favicon', 'adminetic/static/favicon.png')) : config('adminetic.favicon', 'adminetic/static/favicon.png'), config('adminetic.favicon', 'adminetic/static/favicon.png')); |
|
111 | + return getImg(!is_null(setting('favicon')) ? setting('favicon', config('adminetic.favicon', 'adminetic/static/favicon.png')) : config('adminetic.favicon', 'adminetic/static/favicon.png'), config('adminetic.favicon', 'adminetic/static/favicon.png')); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | -if (! function_exists('logo')) { |
|
115 | +if (!function_exists('logo')) { |
|
116 | 116 | function logo() |
117 | 117 | { |
118 | - return getImg(! is_null(setting('logo')) ? setting('logo', config('adminetic.logo', 'adminetic/static/logo.png')) : config('adminetic.logo', 'adminetic/static/logo.png'), config('adminetic.logo', 'adminetic/static/logo.png')); |
|
118 | + return getImg(!is_null(setting('logo')) ? setting('logo', config('adminetic.logo', 'adminetic/static/logo.png')) : config('adminetic.logo', 'adminetic/static/logo.png'), config('adminetic.logo', 'adminetic/static/logo.png')); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | -if (! function_exists('dark_logo')) { |
|
122 | +if (!function_exists('dark_logo')) { |
|
123 | 123 | function dark_logo() |
124 | 124 | { |
125 | - return getImg(! is_null(setting('dark_logo')) ? setting('dark_logo', config('adminetic.dark_logo', 'adminetic/static/dark_logo.png')) : config('adminetic.dark_logo', 'adminetic/static/dark_logo.png'), config('adminetic.dark_logo', 'adminetic/static/dark_logo.png')); |
|
125 | + return getImg(!is_null(setting('dark_logo')) ? setting('dark_logo', config('adminetic.dark_logo', 'adminetic/static/dark_logo.png')) : config('adminetic.dark_logo', 'adminetic/static/dark_logo.png'), config('adminetic.dark_logo', 'adminetic/static/dark_logo.png')); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | -if (! function_exists('logoBanner')) { |
|
129 | +if (!function_exists('logoBanner')) { |
|
130 | 130 | function logoBanner() |
131 | 131 | { |
132 | - return getImg(! is_null(setting('logo_banner')) ? setting('logo_banner', config('adminetic.logo_banner', 'adminetic/static/logo_banner.jpg')) : config('adminetic.logo_banner', 'adminetic/static/logo_banner.jpg'), config('adminetic.logo_banner', 'adminetic/static/logo_banner.jpg')); |
|
132 | + return getImg(!is_null(setting('logo_banner')) ? setting('logo_banner', config('adminetic.logo_banner', 'adminetic/static/logo_banner.jpg')) : config('adminetic.logo_banner', 'adminetic/static/logo_banner.jpg'), config('adminetic.logo_banner', 'adminetic/static/logo_banner.jpg')); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | -if (! function_exists('login_register_bg_image')) { |
|
136 | +if (!function_exists('login_register_bg_image')) { |
|
137 | 137 | function login_register_bg_image() |
138 | 138 | { |
139 | - return getImg(! is_null(setting('login_register_bg_image')) ? setting('login_register_bg_image', config('adminetic.login_register_bg_img', 'adminetic/static/login_register_bg_img.jpg')) : config('adminetic.login_register_bg_img', 'adminetic/static/login_register_bg_img.jpg'), config('adminetic.login_register_bg_img', 'adminetic/static/login_register_bg_img.jpg')); |
|
139 | + return getImg(!is_null(setting('login_register_bg_image')) ? setting('login_register_bg_image', config('adminetic.login_register_bg_img', 'adminetic/static/login_register_bg_img.jpg')) : config('adminetic.login_register_bg_img', 'adminetic/static/login_register_bg_img.jpg'), config('adminetic.login_register_bg_img', 'adminetic/static/login_register_bg_img.jpg')); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | -if (! function_exists('getLazyLoadImg')) { |
|
143 | +if (!function_exists('getLazyLoadImg')) { |
|
144 | 144 | function getLazyLoadImg() |
145 | 145 | { |
146 | 146 | return asset('adminetic/static/loader.svg'); |
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | -if (! function_exists('random_color_part')) { |
|
150 | +if (!function_exists('random_color_part')) { |
|
151 | 151 | function random_color_part() |
152 | 152 | { |
153 | 153 | return str_pad(dechex(mt_rand(0, 255)), 2, '0', STR_PAD_LEFT); |
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | -if (! function_exists('random_color')) { |
|
157 | +if (!function_exists('random_color')) { |
|
158 | 158 | function random_color() |
159 | 159 | { |
160 | 160 | return random_color_part().random_color_part().random_color_part(); |
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | -if (! function_exists('setting')) { |
|
164 | +if (!function_exists('setting')) { |
|
165 | 165 | function setting($setting_name, $default = null) |
166 | 166 | { |
167 | 167 | $valid_setting_name = strtolower(str_replace(' ', '_', $setting_name)); |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | -if (! function_exists('preference')) { |
|
174 | +if (!function_exists('preference')) { |
|
175 | 175 | function preference($preference_name, bool $default = null) |
176 | 176 | { |
177 | 177 | $valid_preference_name = strtolower(str_replace(' ', '_', $preference_name)); |
@@ -185,39 +185,39 @@ discard block |
||
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | -if (! function_exists('deleteImage')) { |
|
188 | +if (!function_exists('deleteImage')) { |
|
189 | 189 | function deleteImage($image) |
190 | 190 | { |
191 | 191 | $image ? (\Illuminate\Support\Facades\File::exists(public_path('storage/'.$image)) ? \Illuminate\Support\Facades\File::delete(public_path('storage/'.$image)) : '') : ''; |
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | -if (! function_exists('api_paginate_limit')) { |
|
195 | +if (!function_exists('api_paginate_limit')) { |
|
196 | 196 | function api_paginate_limit($default = null) |
197 | 197 | { |
198 | 198 | return setting('api_paginate_limit', $default ?? config('adminetic.api_paginate_limit', 10)); |
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | -if (! function_exists('api_collection_return_paginate')) { |
|
202 | +if (!function_exists('api_collection_return_paginate')) { |
|
203 | 203 | function api_collection_return_paginate() |
204 | 204 | { |
205 | 205 | return setting('api_collection_return_paginate', config('adminetic.api_collection_return_paginate', true)); |
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
209 | -if (! function_exists('darkMode')) { |
|
209 | +if (!function_exists('darkMode')) { |
|
210 | 210 | function darkMode() |
211 | 211 | { |
212 | 212 | return setting('dark_mode', config('adminetic.dark_mode', false)); |
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
216 | -if (! function_exists('getCondition')) { |
|
216 | +if (!function_exists('getCondition')) { |
|
217 | 217 | function getCondition($conditions) |
218 | 218 | { |
219 | 219 | $result = null; |
220 | - if (! isset($conditions)) { |
|
220 | + if (!isset($conditions)) { |
|
221 | 221 | return false; |
222 | 222 | } |
223 | 223 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | -if (! function_exists('getImg')) { |
|
246 | +if (!function_exists('getImg')) { |
|
247 | 247 | function getImg($img, $default) |
248 | 248 | { |
249 | 249 | if (isset($img)) { |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
263 | -if (! function_exists('putContentToClassFunction')) { |
|
263 | +if (!function_exists('putContentToClassFunction')) { |
|
264 | 264 | function putContentToClassFunction($file, $function_name, $data, $closing_token = '}') |
265 | 265 | { |
266 | 266 | $data = $data."\n"; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
298 | -if (! function_exists('checkIfFieldIsRequired')) { |
|
298 | +if (!function_exists('checkIfFieldIsRequired')) { |
|
299 | 299 | function checkIfFieldIsRequired($table_name, $field) |
300 | 300 | { |
301 | 301 | $isNullable = null; |
@@ -312,11 +312,11 @@ discard block |
||
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | -if (! function_exists('label')) { |
|
315 | +if (!function_exists('label')) { |
|
316 | 316 | function label($table, $field, $default_label = null) |
317 | 317 | { |
318 | 318 | $display_name = $default_label ?? Str::ucfirst(str_replace('_', ' ', $field)); |
319 | - if (! checkIfFieldIsRequired($table, $field)) { |
|
319 | + if (!checkIfFieldIsRequired($table, $field)) { |
|
320 | 320 | // do something if phone_number is nullable |
321 | 321 | echo "{$display_name} <span class='text-danger'>*</span>"; |
322 | 322 | } else { |
@@ -325,12 +325,12 @@ discard block |
||
325 | 325 | } |
326 | 326 | } |
327 | 327 | |
328 | -if (! function_exists('role_theme')) { |
|
328 | +if (!function_exists('role_theme')) { |
|
329 | 329 | function role_theme() |
330 | 330 | { |
331 | 331 | $role = auth()->check() ? auth()->user()->roles->first()->name : null; |
332 | 332 | $role_theme = config('adminetic.role_theme', null); |
333 | - if (! is_null($role_theme)) { |
|
333 | + if (!is_null($role_theme)) { |
|
334 | 334 | return isset($role_theme[$role]) ? $role_theme[$role] : 'compact-sidebar'; |
335 | 335 | } |
336 | 336 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
341 | -if (! function_exists('setEnvValue')) { |
|
341 | +if (!function_exists('setEnvValue')) { |
|
342 | 342 | function setEnvValue(array $values) |
343 | 343 | { |
344 | 344 | $envFile = app()->environmentFilePath(); |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $oldLine = substr($str, $keyPosition, $endOfLinePosition - $keyPosition); |
353 | 353 | |
354 | 354 | // If key does not exist, add it |
355 | - if (! $keyPosition || ! $endOfLinePosition || ! $oldLine) { |
|
355 | + if (!$keyPosition || !$endOfLinePosition || !$oldLine) { |
|
356 | 356 | $str .= "{$envKey}={$envValue}\n"; |
357 | 357 | } else { |
358 | 358 | $str = str_replace($oldLine, "{$envKey}={$envValue}", $str); |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | } |
362 | 362 | |
363 | 363 | $str = substr($str, 0, -1); |
364 | - if (! file_put_contents($envFile, $str)) { |
|
364 | + if (!file_put_contents($envFile, $str)) { |
|
365 | 365 | return false; |
366 | 366 | } |
367 | 367 |