Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| UserFieldInjectionResource | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| toArray | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Resources\v2; |
| 4 | |
| 5 | use Illuminate\Http\Request; |
| 6 | use Illuminate\Http\Resources\Json\JsonResource; |
| 7 | |
| 8 | /** |
| 9 | * Resource for transforming UserFieldInjection model for API responses. |
| 10 | * |
| 11 | * @property string $_id |
| 12 | * @property string $user_id |
| 13 | * @property array|null $field_injection |
| 14 | * @property array|null $removed_entries |
| 15 | * @property \Carbon\Carbon|null $created_at |
| 16 | * @property \Carbon\Carbon|null $updated_at |
| 17 | */ |
| 18 | class UserFieldInjectionResource extends JsonResource |
| 19 | { |
| 20 | /** |
| 21 | * Transform the resource into an array. |
| 22 | * |
| 23 | * @return array<string, mixed> |
| 24 | */ |
| 25 | public function toArray(Request $request): array |
| 26 | { |
| 27 | return [ |
| 28 | 'user_id' => $this->user_id, |
| 29 | 'field_injection' => $this->field_injection ?? [], |
| 30 | 'removed_entries' => $this->removed_entries ?? [], |
| 31 | 'updated_at' => $this->updated_at?->timestamp, |
| 32 | ]; |
| 33 | } |
| 34 | } |