Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| PromptWritingGoalResource | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| toArray | |
100.00% |
8 / 8 |
|
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 PromptWritingGoal models for API responses. |
| 10 | * |
| 11 | * @property string $_id The writing goal ID |
| 12 | * @property string $title The goal title |
| 13 | * @property string $description The goal description |
| 14 | * @property string $prompt The goal prompt text |
| 15 | * @property \Carbon\Carbon|null $created_at |
| 16 | * @property \Carbon\Carbon|null $updated_at |
| 17 | */ |
| 18 | class PromptWritingGoalResource 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 | 'id' => (string) $this->_id, |
| 29 | 'title' => $this->title, |
| 30 | 'description' => $this->description, |
| 31 | 'prompt' => $this->prompt, |
| 32 | 'created_at' => $this->created_at?->timestamp, |
| 33 | 'updated_at' => $this->updated_at?->timestamp, |
| 34 | ]; |
| 35 | } |
| 36 | } |