<?php
 namespace App\Http\Requests\Admin\ProductConfigOption; use App\Models\ProductConfigOption; use Illuminate\Foundation\Http\FormRequest; class ForceDeleteOptionRequest extends FormRequest { public function authorize(): bool { $option = ProductConfigOption::findOrFail($this->route('id')); $this->merge(['_option' => $option]); return $this->user('admin')?->can('forceDelete', $option) ?? false; } public function rules(): array { $option = $this->input('_option'); return [ 'confirmation_text' => ['required', 'string', function ($attr, $value, $fail) use ($option) { if (trim(strtolower((string) $value)) !== trim(strtolower($option->name))) { $fail(trans('admin/product-config-options.confirm_force_delete_mismatch')); } }], ]; } } 