check() and $this->ajax(); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(): array { return [ 'token' => [ 'required', 'string', function ($attribute, $value, $fail) { try { $payload = json_decode(Crypt::decryptString($value), true); if (!is_array($payload) || !isset($payload['modelName'], $payload['modelId'])) { $fail("Le {$attribute} est invalide."); } } catch (\Illuminate\Contracts\Encryption\DecryptException $e) { $fail("Le {$attribute} est invalide."); } }, ], ]; } }