Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
25 / 25 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| CompanyRolePlayProjectResource | |
100.00% |
25 / 25 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| toArray | |
100.00% |
25 / 25 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Resources\v2; |
| 4 | |
| 5 | use Illuminate\Http\Resources\Json\JsonResource; |
| 6 | |
| 7 | /** |
| 8 | * Resource for transforming CompanyRolePlayProject models for API responses. |
| 9 | * |
| 10 | * Transforms company-level roleplay projects including all configuration |
| 11 | * fields and computed creator information. |
| 12 | * |
| 13 | * @property string $_id The project ID |
| 14 | * @property string $company_id The owning company ID |
| 15 | * @property string $created_by The creator user ID |
| 16 | * @property string $name The project name |
| 17 | * @property string $type The call type (e.g., 'cold-call', 'discovery-call') |
| 18 | * @property string|null $description The project description |
| 19 | * @property string $industry The target industry |
| 20 | * @property array $target_job_titles Array of targeted job titles |
| 21 | * @property array $key_features Array of key product/service features |
| 22 | * @property string|null $product_description Product description |
| 23 | * @property int $difficulty_level Difficulty level (1-5) |
| 24 | * @property array $customer_profiles Array of customer profile objects |
| 25 | * @property array $training_personalities Array of training personality configurations |
| 26 | * @property array $scorecard_config Array of scorecard configuration objects |
| 27 | * @property array $objections Array of objection objects |
| 28 | * @property bool $allow_user_customization Whether users can customize when cloning |
| 29 | * @property array $assigned_groups Array of assigned group IDs |
| 30 | * @property string $status Project status ('active', 'inactive', 'archived') |
| 31 | * @property \App\Http\Models\Auth\User|null $creator The user who created this project |
| 32 | * @property \Carbon\Carbon|null $created_at |
| 33 | * @property \Carbon\Carbon|null $updated_at |
| 34 | */ |
| 35 | class CompanyRolePlayProjectResource extends JsonResource |
| 36 | { |
| 37 | /** |
| 38 | * Transform the resource into an array. |
| 39 | * |
| 40 | * @param \Illuminate\Http\Request $request |
| 41 | * @return array<string, mixed> |
| 42 | */ |
| 43 | public function toArray($request): array |
| 44 | { |
| 45 | return [ |
| 46 | 'id' => (string) $this->_id, |
| 47 | 'company_id' => $this->company_id, |
| 48 | 'created_by' => $this->created_by, |
| 49 | 'creator_name' => $this->whenLoaded('creator', function () { |
| 50 | return $this->creator?->first_name . ' ' . $this->creator?->last_name; |
| 51 | }), |
| 52 | 'name' => $this->name, |
| 53 | 'type' => $this->type, |
| 54 | 'description' => $this->description, |
| 55 | 'industry' => $this->industry, |
| 56 | 'target_job_titles' => $this->target_job_titles ?? [], |
| 57 | 'key_features' => $this->key_features ?? [], |
| 58 | 'product_description' => $this->product_description, |
| 59 | 'difficulty_level' => (int) $this->difficulty_level, |
| 60 | 'customer_profiles' => $this->customer_profiles ?? [], |
| 61 | 'training_personalities' => $this->training_personalities ?? [], |
| 62 | 'scorecard_config' => $this->scorecard_config ?? [], |
| 63 | 'objections' => $this->objections ?? [], |
| 64 | 'allow_user_customization' => (bool) $this->allow_user_customization, |
| 65 | 'assigned_groups' => $this->assigned_groups ?? [], |
| 66 | 'status' => $this->status, |
| 67 | 'created_at' => $this->created_at?->timestamp, |
| 68 | 'updated_at' => $this->updated_at?->timestamp, |
| 69 | ]; |
| 70 | } |
| 71 | } |