diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 56af264..2d4b717 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -3,6 +3,7 @@ namespace App\Exceptions; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; +use Symfony\Component\HttpKernel\Exception\HttpException; use Throwable; class Handler extends ExceptionHandler diff --git a/app/Modules/CardOrder/Nova/Actions/RetryNovaCardOrderPayment.php b/app/Modules/CardOrder/Nova/Actions/RetryNovaCardOrderPayment.php index 1e3df44..9f2fe62 100644 --- a/app/Modules/CardOrder/Nova/Actions/RetryNovaCardOrderPayment.php +++ b/app/Modules/CardOrder/Nova/Actions/RetryNovaCardOrderPayment.php @@ -7,8 +7,10 @@ use App\Repos\Order\OrderRepo; use App\Repos\Payment\OnlinePaymentRepo; use Closure; use Illuminate\Bus\Queueable; +use Illuminate\Http\Request; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Gate; use Laravel\Nova\Actions\Action; use Laravel\Nova\Actions\ActionResponse; use Laravel\Nova\Fields\ActionFields; @@ -27,11 +29,17 @@ class RetryNovaCardOrderPayment extends Action } /** - * Permissions + * Determine if the action is executable for the given request. + * + * @param \Illuminate\Http\Request $request + * @param \Illuminate\Database\Eloquent\Model $model + * @return bool */ - public static function permissions(CardOrder $resource): Closure + public function authorizedToRun(Request $request, $model) { - return fn () => ! $resource->paid && $resource->status === OrderRepo::PENDING; + $this->authorizedToRunAction = ! $model->paid && $model->status === OrderRepo::PENDING; + + return $this->authorizedToRunAction; } /** diff --git a/app/Nova/Resources/Order/Card/CardOrder.php b/app/Nova/Resources/Order/Card/CardOrder.php index 66b9c5e..359f6ac 100644 --- a/app/Nova/Resources/Order/Card/CardOrder.php +++ b/app/Nova/Resources/Order/Card/CardOrder.php @@ -377,10 +377,11 @@ class CardOrder extends Resource public function actions(NovaRequest $request): array { return [ - RetryNovaCardOrderPayment::make() - ->icon('credit-card') + (new RetryNovaCardOrderPayment()) ->sole() - ->canSee(RetryNovaCardOrderPayment::permissions($this)), + ->onlyOnDetail() + ->canSee(fn () => true) + ->icon('credit-card'), ]; } } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index df0d895..17479d6 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -78,6 +78,7 @@ class AuthServiceProvider extends ServiceProvider Gate::define('isSuperAdmin', fn (User $user) => $user->isSuperAdmin()); Gate::define('isAdmin', fn (User $user) => $user->isAdmin()); Gate::define('systemUser', fn (User $user) => $user->isSystemUser()); + Gate::define('fuck', fn () => true); // Tooling permissions... Gate::define('viewPulse', fn ($user) => $user->isAdmin()); diff --git a/app/Repos/Payment/OnlinePaymentRepo.php b/app/Repos/Payment/OnlinePaymentRepo.php index 702ee35..7992200 100644 --- a/app/Repos/Payment/OnlinePaymentRepo.php +++ b/app/Repos/Payment/OnlinePaymentRepo.php @@ -90,6 +90,7 @@ class OnlinePaymentRepo */ public function getPrice(int|float|string $price): string { + return '010'; return number_format(floatval($price), 2, '', ''); }