diff --git a/src/Helpers/AdminHelper.php b/src/Helpers/AdminHelper.php index e7d7fd1..f0c741a 100644 --- a/src/Helpers/AdminHelper.php +++ b/src/Helpers/AdminHelper.php @@ -1,18 +1,18 @@ ', '&', '{', '*', '\\', '/', ':', '.', ';', ',', "'", '"'], '_', $name ?? trim($default))); } } -if (!function_exists('getImagePlaceholder')) { +if (! function_exists('getImagePlaceholder')) { function getImagePlaceholder() { return asset(config('adminetic.default_image_placeholder', 'adminetic/static/placeholder.png')); } } -if (!function_exists('getVerticalImagePlaceholder')) { +if (! function_exists('getVerticalImagePlaceholder')) { function getVerticalImagePlaceholder() { return asset(config('adminetic.vertical_image_placeholder', 'adminetic/static/vertical_placeholder.jpg')); } } -if (!function_exists('getSliderPlaceholder')) { +if (! function_exists('getSliderPlaceholder')) { function getSliderPlaceholder() { return asset(config('adminetic.slider_placeholder', 'adminetic/static/slider.jpg')); } } -if (!function_exists('getProfilePlaceholder')) { +if (! function_exists('getProfilePlaceholder')) { function getProfilePlaceholder($p = null) { $profile = $p ?? Auth::user()->profile ?? Auth::user()->profile()->create(); - return isset($profile->profile_pic) ? (Illuminate\Support\Str::contains($profile->profile_pic, ['https://', 'http://']) ? $profile->profile_pic : asset('storage/' . $profile->profile_pic)) : asset(config('adminetic.profile_placeholder', 'adminetic/static/profile.gif')); + return isset($profile->profile_pic) ? (Illuminate\Support\Str::contains($profile->profile_pic, ['https://', 'http://']) ? $profile->profile_pic : asset('storage/'.$profile->profile_pic)) : asset(config('adminetic.profile_placeholder', 'adminetic/static/profile.gif')); } } -if (!function_exists('title')) { +if (! function_exists('title')) { function title() { return setting('title', config('adminetic.name', 'Adminetic')); } } -if (!function_exists('description')) { +if (! function_exists('description')) { function description($default = null) { return setting('description', config('adminetic.description', $default ?? 'Adminetic Admin Panel')); } } -if (!function_exists('keywords')) { +if (! function_exists('keywords')) { function keywords() { return setting('keywords', config('adminetic.keywords', 'adminetic admin panel, adminetic, pratik shrestha, doctype innovations')); } } -if (!function_exists('loader_enabled')) { +if (! function_exists('loader_enabled')) { function loader_enabled() { return setting('loader_enabled', config('adminetic.loader_enabled', true)); } } -if (!function_exists('favicon')) { +if (! function_exists('favicon')) { function favicon() { - 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')); + 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')); } } -if (!function_exists('logo')) { +if (! function_exists('logo')) { function logo() { - 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')); + 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')); } } -if (!function_exists('dark_logo')) { +if (! function_exists('dark_logo')) { function dark_logo() { - 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')); + 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')); } } -if (!function_exists('logoBanner')) { +if (! function_exists('logoBanner')) { function logoBanner() { - 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')); + 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')); } } -if (!function_exists('login_register_bg_image')) { +if (! function_exists('login_register_bg_image')) { function login_register_bg_image() { - 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')); + 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')); } } -if (!function_exists('getLazyLoadImg')) { +if (! function_exists('getLazyLoadImg')) { function getLazyLoadImg() { return asset('adminetic/static/loader.svg'); } } -if (!function_exists('random_color_part')) { +if (! function_exists('random_color_part')) { function random_color_part() { return str_pad(dechex(mt_rand(0, 255)), 2, '0', STR_PAD_LEFT); } } -if (!function_exists('random_color')) { +if (! function_exists('random_color')) { function random_color() { - return random_color_part() . random_color_part() . random_color_part(); + return random_color_part().random_color_part().random_color_part(); } } -if (!function_exists('setting')) { +if (! function_exists('setting')) { function setting($setting_name, $default = null) { $valid_setting_name = strtolower(str_replace(' ', '_', $setting_name)); @@ -175,12 +175,11 @@ function setting($setting_name, $default = null) return $s->getRawOriginal('setting_name') == $valid_setting_name; }); - return isset($setting->value) ? $setting->value : ($default ?? null); } } -if (!function_exists('preference')) { +if (! function_exists('preference')) { function preference($preference_name, bool $default = null) { $valid_preference_name = strtolower(str_replace(' ', '_', $preference_name)); @@ -194,39 +193,39 @@ function preference($preference_name, bool $default = null) } } -if (!function_exists('deleteImage')) { +if (! function_exists('deleteImage')) { function deleteImage($image) { - $image ? (\Illuminate\Support\Facades\File::exists(public_path('storage/' . $image)) ? \Illuminate\Support\Facades\File::delete(public_path('storage/' . $image)) : '') : ''; + $image ? (\Illuminate\Support\Facades\File::exists(public_path('storage/'.$image)) ? \Illuminate\Support\Facades\File::delete(public_path('storage/'.$image)) : '') : ''; } } -if (!function_exists('api_paginate_limit')) { +if (! function_exists('api_paginate_limit')) { function api_paginate_limit($default = null) { return setting('api_paginate_limit', $default ?? config('adminetic.api_paginate_limit', 10)); } } -if (!function_exists('api_collection_return_paginate')) { +if (! function_exists('api_collection_return_paginate')) { function api_collection_return_paginate() { return setting('api_collection_return_paginate', config('adminetic.api_collection_return_paginate', true)); } } -if (!function_exists('darkMode')) { +if (! function_exists('darkMode')) { function darkMode() { return setting('dark_mode', config('adminetic.dark_mode', false)); } } -if (!function_exists('getCondition')) { +if (! function_exists('getCondition')) { function getCondition($conditions) { $result = null; - if (!isset($conditions)) { + if (! isset($conditions)) { return false; } @@ -252,12 +251,12 @@ function getCondition($conditions) } } -if (!function_exists('getImg')) { +if (! function_exists('getImg')) { function getImg($img, $default) { if (isset($img)) { - if (file_exists(public_path('storage/' . $img))) { - return asset('storage/' . $img); + if (file_exists(public_path('storage/'.$img))) { + return asset('storage/'.$img); } elseif (file_exists(public_path($img))) { return asset($img); } else { @@ -269,10 +268,10 @@ function getImg($img, $default) } } -if (!function_exists('putContentToClassFunction')) { +if (! function_exists('putContentToClassFunction')) { function putContentToClassFunction($file, $function_name, $data, $closing_token = '}') { - $data = $data . "\n"; + $data = $data."\n"; // Read the contents of the file into a string $contents = file_get_contents($file); @@ -292,7 +291,7 @@ function putContentToClassFunction($file, $function_name, $data, $closing_token $function_definition = substr($contents, $start_pos, $end_pos - $start_pos + 1); // Append the new content to the function definition - $modified_function_definition = rtrim($function_definition, $closing_token) . $data . $closing_token; + $modified_function_definition = rtrim($function_definition, $closing_token).$data.$closing_token; // Replace the original function definition with the modified one in the class definition $modified_contents = substr_replace($contents, $modified_function_definition, $start_pos, $end_pos - $start_pos + 1); @@ -304,7 +303,7 @@ function putContentToClassFunction($file, $function_name, $data, $closing_token } } -if (!function_exists('checkIfFieldIsRequired')) { +if (! function_exists('checkIfFieldIsRequired')) { function checkIfFieldIsRequired($table_name, $field) { $isNullable = null; @@ -321,11 +320,11 @@ function checkIfFieldIsRequired($table_name, $field) } } -if (!function_exists('label')) { +if (! function_exists('label')) { function label($table, $field, $default_label = null) { $display_name = $default_label ?? Str::ucfirst(str_replace('_', ' ', $field)); - if (!checkIfFieldIsRequired($table, $field)) { + if (! checkIfFieldIsRequired($table, $field)) { // do something if phone_number is nullable echo "{$display_name} *"; } else { @@ -334,12 +333,12 @@ function label($table, $field, $default_label = null) } } -if (!function_exists('role_theme')) { +if (! function_exists('role_theme')) { function role_theme() { $role = auth()->check() ? auth()->user()->roles->first()->name : null; $role_theme = config('adminetic.role_theme', null); - if (!is_null($role_theme)) { + if (! is_null($role_theme)) { return isset($role_theme[$role]) ? $role_theme[$role] : 'compact-sidebar'; } @@ -347,7 +346,7 @@ function role_theme() } } -if (!function_exists('setEnvValue')) { +if (! function_exists('setEnvValue')) { function setEnvValue(array $values) { $envFile = app()->environmentFilePath(); @@ -361,7 +360,7 @@ function setEnvValue(array $values) $oldLine = substr($str, $keyPosition, $endOfLinePosition - $keyPosition); // If key does not exist, add it - if (!$keyPosition || !$endOfLinePosition || !$oldLine) { + if (! $keyPosition || ! $endOfLinePosition || ! $oldLine) { $str .= "{$envKey}={$envValue}\n"; } else { $str = str_replace($oldLine, "{$envKey}={$envValue}", $str); @@ -370,7 +369,7 @@ function setEnvValue(array $values) } $str = substr($str, 0, -1); - if (!file_put_contents($envFile, $str)) { + if (! file_put_contents($envFile, $str)) { return false; } diff --git a/src/Providers/AdmineticServiceProvider.php b/src/Providers/AdmineticServiceProvider.php index 88129d2..2cf8a68 100644 --- a/src/Providers/AdmineticServiceProvider.php +++ b/src/Providers/AdmineticServiceProvider.php @@ -39,11 +39,9 @@ use Pratiksh\Adminetic\Http\Middleware\RoleMiddleware; use Pratiksh\Adminetic\Mixins\AdmineticAuthMixins; use Pratiksh\Adminetic\Models\Admin\Preference; -use Pratiksh\Adminetic\Models\Admin\Setting as AdminSetting; use Pratiksh\Adminetic\Models\Permission; use Pratiksh\Adminetic\Models\Role; use Pratiksh\Adminetic\Models\Setting; -use Pratiksh\Adminetic\Observers\SettingObserver; use Pratiksh\Adminetic\Policies\PermissionPolicy; use Pratiksh\Adminetic\Policies\PreferencePolicy; use Pratiksh\Adminetic\Policies\RolePolicy; @@ -137,26 +135,26 @@ protected function publishResource() { // Publish Config File $this->publishes([ - __DIR__ . '/../../config/adminetic.php' => config_path('adminetic.php'), + __DIR__.'/../../config/adminetic.php' => config_path('adminetic.php'), ], 'adminetic-config'); // Publish View Files $this->publishes([ - __DIR__ . '/../../resources/views' => resource_path('views/vendor/adminetic'), + __DIR__.'/../../resources/views' => resource_path('views/vendor/adminetic'), ], 'adminetic-views'); // Publish Migration Files $this->publishes([ - __DIR__ . '/../../database/migrations' => database_path('migrations'), + __DIR__.'/../../database/migrations' => database_path('migrations'), ], 'adminetic-migrations'); // Publish Database Seeds $this->publishes([ - __DIR__ . '/../../database/seeders' => database_path('seeders'), + __DIR__.'/../../database/seeders' => database_path('seeders'), ], 'adminetic-seeders'); $this->publishes([ - __DIR__ . '/../../payload/assets' => public_path('adminetic/assets'), + __DIR__.'/../../payload/assets' => public_path('adminetic/assets'), ], 'adminetic-assets-files'); // Publish Static Files $this->publishes([ - __DIR__ . '/../../payload/static' => public_path('adminetic/static'), + __DIR__.'/../../payload/static' => public_path('adminetic/static'), ], 'adminetic-static-files'); } @@ -167,8 +165,8 @@ protected function publishResource() */ protected function registerResource() { - $this->loadMigrationsFrom(__DIR__ . '/../../database/migrations'); // Loading Migration Files - $this->loadViewsFrom(__DIR__ . '/../../resources/views', 'adminetic'); // Loading Views Files + $this->loadMigrationsFrom(__DIR__.'/../../database/migrations'); // Loading Migration Files + $this->loadViewsFrom(__DIR__.'/../../resources/views', 'adminetic'); // Loading Views Files $this->registerRoutes(); } @@ -180,7 +178,7 @@ protected function registerResource() protected function registerRoutes() { Route::group($this->routeConfiguration(), function () { - $this->loadRoutesFrom(__DIR__ . '/../../routes/web.php'); + $this->loadRoutesFrom(__DIR__.'/../../routes/web.php'); }); }