From 382317f1ae15c4d9780778317746eba65602dfff Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Thu, 14 Dec 2023 20:23:27 +0500 Subject: [PATCH] add ability to show backups to superadmins --- app/Nova/Resources/Branch/Branch.php | 3 ++- app/Providers/NovaServiceProvider.php | 2 +- app/Repos/System/Nova/NovaRepo.php | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Nova/Resources/Branch/Branch.php b/app/Nova/Resources/Branch/Branch.php index fda60fc..096347a 100644 --- a/app/Nova/Resources/Branch/Branch.php +++ b/app/Nova/Resources/Branch/Branch.php @@ -9,6 +9,7 @@ use App\Repos\System\Nova\NovaRepo; use App\Repos\System\Settings\Location\RegionRepo; use Illuminate\Http\Request; use Laravel\Nova\Fields\ID; +use Laravel\Nova\Fields\Password; use Laravel\Nova\Fields\Select; use Laravel\Nova\Fields\Text; use Laravel\Nova\Fields\Textarea; @@ -88,7 +89,7 @@ class Branch extends Resource Text::make(__('Billing username'), 'billing_username') ->rules('nullable', 'string', 'max:255'), - Text::make(__('Billing password'), 'billing_password') + Password::make(__('Billing password'), 'billing_password') ->rules('nullable', 'string', 'max:255'), Textarea::make(__('Address'), 'address'), diff --git a/app/Providers/NovaServiceProvider.php b/app/Providers/NovaServiceProvider.php index e34492d..e7cbd44 100644 --- a/app/Providers/NovaServiceProvider.php +++ b/app/Providers/NovaServiceProvider.php @@ -98,7 +98,7 @@ class NovaServiceProvider extends NovaApplicationServiceProvider ->onSwitchLocale(NovaRepo::localeSwitcherSave()), BackupTool::make() - ->canSee(NovaRepo::isMe()), + ->canSee(NovaRepo::isAdmin()), LogsTool::make() ->canSee(NovaRepo::isMe()) diff --git a/app/Repos/System/Nova/NovaRepo.php b/app/Repos/System/Nova/NovaRepo.php index cd8441b..b8808b3 100644 --- a/app/Repos/System/Nova/NovaRepo.php +++ b/app/Repos/System/Nova/NovaRepo.php @@ -83,6 +83,14 @@ class NovaRepo return fn () => Gate::allows('isMe', auth()->user()); } + /** + * Check if user is admin + */ + public function isAdmin(): Closure + { + return fn () => Gate::allows('isAdmin', auth()->user()); + } + /** * Readonly only on "update" pages */