Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
29 / 29 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| CompanyRolePlayProjectWithAssignmentResource | |
100.00% |
29 / 29 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| toArray | |
100.00% |
29 / 29 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Resources\v2; |
| 4 | |
| 5 | use Illuminate\Http\Resources\Json\JsonResource; |
| 6 | |
| 7 | /** |
| 8 | * Admin-facing variant of {@see CompanyRolePlayProjectResource} that |
| 9 | * additionally exposes the assignment metadata (groups, users, clone/direct |
| 10 | * call toggles). End-user endpoints must NOT surface these fields. |
| 11 | * |
| 12 | * @property string $_id |
| 13 | * @property string $company_id |
| 14 | * @property string $created_by |
| 15 | * @property string $name |
| 16 | * @property string $type |
| 17 | * @property string|null $description |
| 18 | * @property array $industry |
| 19 | * @property array|null $target_job_titles |
| 20 | * @property array|null $key_features |
| 21 | * @property string|null $product_description |
| 22 | * @property int $difficulty_level |
| 23 | * @property array $customer_profiles |
| 24 | * @property array $scorecard_config |
| 25 | * @property array $objections |
| 26 | * @property bool $allow_user_customization |
| 27 | * @property bool $allow_clone |
| 28 | * @property bool $allow_direct_calls |
| 29 | * @property array $assigned_groups |
| 30 | * @property array $assigned_users |
| 31 | * @property string $status |
| 32 | * @property \App\Http\Models\Auth\User|null $creator |
| 33 | * @property \Carbon\Carbon|null $created_at |
| 34 | * @property \Carbon\Carbon|null $updated_at |
| 35 | */ |
| 36 | class CompanyRolePlayProjectWithAssignmentResource extends JsonResource |
| 37 | { |
| 38 | /** |
| 39 | * @return array<string, mixed> |
| 40 | */ |
| 41 | public function toArray($request): array |
| 42 | { |
| 43 | $allowClone = $this->allow_clone ?? $this->allow_user_customization; |
| 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 | 'company_sizes' => $this->company_sizes ?? [], |
| 58 | 'key_features' => $this->key_features ?? [], |
| 59 | 'product_description' => $this->product_description, |
| 60 | 'difficulty_level' => (int) $this->difficulty_level, |
| 61 | 'customer_profiles' => $this->customer_profiles ?? [], |
| 62 | 'scorecard_config' => $this->scorecard_config ?? [], |
| 63 | 'objections' => $this->objections ?? [], |
| 64 | 'allow_user_customization' => (bool) $this->allow_user_customization, |
| 65 | 'allow_clone' => (bool) $allowClone, |
| 66 | 'allow_direct_calls' => $this->allow_direct_calls === null ? true : (bool) $this->allow_direct_calls, |
| 67 | 'assigned_groups' => $this->assigned_groups ?? [], |
| 68 | 'assigned_users' => $this->assigned_users ?? [], |
| 69 | 'status' => $this->status, |
| 70 | 'created_at' => $this->created_at?->timestamp, |
| 71 | 'updated_at' => $this->updated_at?->timestamp, |
| 72 | ]; |
| 73 | } |
| 74 | } |