<?php
 namespace App\Http\Requests\Admin; use App\Models\Basket; use Illuminate\Foundation\Http\FormRequest; class BasketDestroyRequest extends FormRequest { public function authorize(): bool { if ($this->input('source') === 'redis') { return $this->user()->can('delete', Basket::class); } $basket = Basket::find($this->route('id')); if ($basket) { return $this->user()->can('delete', $basket); } return $this->user()->can('delete', Basket::class); } public function rules(): array { return [ 'source' => ['sometimes', 'string', 'in:redis,mysql'], 'visitor_id' => ['sometimes', 'string'], ]; } } 