Skip to content

Commit

Permalink
Merge pull request #26 from pratiksh404/analysis-7aZkWV
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
pratiksh404 authored Dec 16, 2021
2 parents 0f5868d + af300fe commit e7e2bf0
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 51 deletions.
64 changes: 32 additions & 32 deletions src/Helpers/AdminHelper.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

if (!function_exists('getClassesList')) {
if (! function_exists('getClassesList')) {
function getClassesList($dir)
{
$classes = \File::allFiles($dir);
Expand All @@ -15,7 +15,7 @@ function getClassesList($dir)
return $classes;
}
}
if (!function_exists('getAllModelNames')) {
if (! function_exists('getAllModelNames')) {
function getAllModelNames($dir)
{
$modelNames = [];
Expand All @@ -29,121 +29,121 @@ function getAllModelNames($dir)
}
}

if (!function_exists('validImageFolder')) {
if (! function_exists('validImageFolder')) {
function validImageFolder($name, $default = 'default')
{
return strtolower(str_replace([' ', '-', '$', '<', '>', '&', '{', '}', '*', '\\', '/', ':', '.', ';', ',', "'", '"'], '_', $name ?? trim($default)));
}
}

if (!function_exists('getImagePlaceholder')) {
if (! function_exists('getImagePlaceholder')) {
function getImagePlaceholder()
{
return asset('adminetic/static/placeholder.png');
}
}

if (!function_exists('getVerticalImagePlaceholder')) {
if (! function_exists('getVerticalImagePlaceholder')) {
function getVerticalImagePlaceholder()
{
return asset('adminetic/static/vertical_placeholder.jpg');
}
}

if (!function_exists('getSliderPlaceholder')) {
if (! function_exists('getSliderPlaceholder')) {
function getSliderPlaceholder()
{
return asset('adminetic/static/slider.jpg');
}
}

if (!function_exists('getFoodImagePlaceholder')) {
if (! function_exists('getFoodImagePlaceholder')) {
function getFoodImagePlaceholder()
{
return asset('adminetic/static/food_placeholder.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('adminetic/static/profile.jpg');
return isset($profile->profile_pic) ? (Illuminate\Support\Str::contains($profile->profile_pic, ['https://', 'http://']) ? $profile->profile_pic : asset('storage/'.$profile->profile_pic)) : asset('adminetic/static/profile.jpg');
}
}

if (!function_exists('title')) {
if (! function_exists('title')) {
function title()
{
return setting('title', config('adminetic.name', 'Adminetic'));
}
}

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 setting('favicon') ? (asset('storage/' . setting('favicon'))) : asset('adminetic/static/favicon.png');
return setting('favicon') ? (asset('storage/'.setting('favicon'))) : asset('adminetic/static/favicon.png');
}
}

if (!function_exists('logo')) {
if (! function_exists('logo')) {
function logo()
{
return setting('logo') ? (asset('storage/' . setting('logo'))) : asset('adminetic/static/logo.png');
return setting('logo') ? (asset('storage/'.setting('logo'))) : asset('adminetic/static/logo.png');
}
}

if (!function_exists('dark_logo')) {
if (! function_exists('dark_logo')) {
function dark_logo()
{
return setting('dark_logo') ? (asset('storage/' . setting('dark_logo'))) : asset('adminetic/static/logo_dark.png');
return setting('dark_logo') ? (asset('storage/'.setting('dark_logo'))) : asset('adminetic/static/logo_dark.png');
}
}

if (!function_exists('getLogoBanner')) {
if (! function_exists('getLogoBanner')) {
function getLogoBanner()
{
return setting('logo_banner') ? (asset('storage/' . setting('logo_banner'))) : asset('adminetic/static/logo_banner.jpg');
return setting('logo_banner') ? (asset('storage/'.setting('logo_banner'))) : asset('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 setting('login_register_bg_image') ? (asset('storage/' . setting('login_register_bg_image'))) : asset('adminetic/static/login_register_bg_img.jpg');
return setting('login_register_bg_image') ? (asset('storage/'.setting('login_register_bg_image'))) : asset('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));
Expand All @@ -153,7 +153,7 @@ function setting($setting_name, $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));
Expand All @@ -167,25 +167,25 @@ 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('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;
}

Expand Down
10 changes: 6 additions & 4 deletions src/Http/Livewire/Admin/User/UserTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Pratiksh\Adminetic\Http\Livewire\Admin\User;

use App\Models\User;
use Illuminate\Support\Facades\Cache;
use Livewire\Component;
use Livewire\WithPagination;
use Illuminate\Support\Facades\Cache;
use Pratiksh\Adminetic\Models\Admin\Role;

class UserTable extends Component
Expand Down Expand Up @@ -33,6 +33,7 @@ public function render()
{
$users = $this->getUsers();
$roles = Cache::get('roles', Role::latest()->get());

return view('adminetic::livewire.admin.user.user-table', compact('users', 'roles'));
}

Expand All @@ -47,9 +48,9 @@ protected function getUsers()
case 2:
$this->resetPage();
$search = $this->search ?? null;
$data = $default->where('name', 'like', '%' . $search . '%')
->orWhere('email', 'like', '%' . $search . '%');
$this->information = 'Showing search results for "' . $search . '"';
$data = $default->where('name', 'like', '%'.$search.'%')
->orWhere('email', 'like', '%'.$search.'%');
$this->information = 'Showing search results for "'.$search.'"';
break;
case 3:
$this->resetPage();
Expand All @@ -62,6 +63,7 @@ protected function getUsers()
$data = $default->latest();
break;
}

return $data->paginate(10);
}
}
18 changes: 9 additions & 9 deletions src/Providers/AdmineticServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,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');
}

Expand All @@ -158,8 +158,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();
}

Expand All @@ -171,7 +171,7 @@ protected function registerResource()
protected function registerRoutes()
{
Route::group($this->routeConfiguration(), function () {
$this->loadRoutesFrom(__DIR__ . '/../../routes/web.php');
$this->loadRoutesFrom(__DIR__.'/../../routes/web.php');
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/Repositories/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function attachPreference($user)
$preferences = Preference::all();
if (isset($preferences)) {
foreach ($preferences as $preference) {
if (!isset($preference->roles)) {
if (! isset($preference->roles)) {
$user->preferences()->attach($preference->id, [
'enabled' => $preference->active,
]);
Expand Down
10 changes: 5 additions & 5 deletions src/Services/Adminetic.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public function admineticMenus(): array
'type' => 'or',
'condition' => auth()->user()->can('create', \Pratiksh\Adminetic\Models\Admin\Setting::class),
],
]
],
],
[
'type' => 'menu',
Expand Down Expand Up @@ -504,8 +504,8 @@ private function indexCreateChildren($route, $class)
$children = [
[
'type' => 'submenu',
'name' => 'All ' . $plural,
'is_active' => request()->routeIs($route . '.index') ? 'active' : '',
'name' => 'All '.$plural,
'is_active' => request()->routeIs($route.'.index') ? 'active' : '',
'link' => adminRedirectRoute($route),
'conditions' => [
[
Expand All @@ -516,8 +516,8 @@ private function indexCreateChildren($route, $class)
],
[
'type' => 'submenu',
'name' => 'Create ' . $route,
'is_active' => request()->routeIs($route . '.create') ? 'active' : '',
'name' => 'Create '.$route,
'is_active' => request()->routeIs($route.'.create') ? 'active' : '',
'link' => adminCreateRoute($route),
'conditions' => [
[
Expand Down

0 comments on commit e7e2bf0

Please sign in to comment.