Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| UpdateRolePlayPersonaTemplateRequest | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
| authorize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| prepareForValidation | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| rules | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Requests\v2\RolePlay; |
| 4 | |
| 5 | use App\Http\Models\RolePlayPersonaTemplate; |
| 6 | use App\Http\Services\RolePlay\ObjectionNormalizer; |
| 7 | use Illuminate\Foundation\Http\FormRequest; |
| 8 | |
| 9 | /** |
| 10 | * Request for updating an existing RolePlay Persona Template. |
| 11 | * |
| 12 | * Same field set as the create request — the service layer enforces |
| 13 | * visibility/ownership checks before persisting. |
| 14 | * |
| 15 | * @property string $name Template display name |
| 16 | * @property string|null $description Short description shown in the picker |
| 17 | * @property string $type Call type (cold-call|discovery-call) |
| 18 | * @property int $difficulty_level Difficulty level (1-5) |
| 19 | * @property array<int, string> $industry Target industries |
| 20 | * @property array<int, string>|null $target_job_titles Target buyer job titles |
| 21 | * @property array<int, string> $company_sizes Targeted company sizes |
| 22 | * @property array<int, string>|null $key_features Product key features |
| 23 | * @property string|null $product_description Product description |
| 24 | * @property array<int, array{category: string, options: array<int, string>}>|null $objections Objection blocks |
| 25 | * @property string $visibility personal|company |
| 26 | */ |
| 27 | class UpdateRolePlayPersonaTemplateRequest extends FormRequest |
| 28 | { |
| 29 | public function authorize(): bool |
| 30 | { |
| 31 | return $this->user() !== null; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Normalize legacy-shape `objections` payloads into the canonical |
| 36 | * {text, company_sizes} shape BEFORE validation rules fire. |
| 37 | */ |
| 38 | protected function prepareForValidation(): void |
| 39 | { |
| 40 | if ($this->has('objections')) { |
| 41 | $this->merge([ |
| 42 | 'objections' => ObjectionNormalizer::normalize($this->input('objections')), |
| 43 | ]); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * @return array<string, mixed> |
| 49 | */ |
| 50 | public function rules(): array |
| 51 | { |
| 52 | return RolePlayPersonaTemplate::getRules(); |
| 53 | } |
| 54 | } |