Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| PromptToneResource | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| toArray | |
100.00% |
7 / 7 |
|
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 PromptTone models for API responses. |
| 10 | * |
| 11 | * @property string $_id The prompt tone ID |
| 12 | * @property string $name The tone name |
| 13 | * @property string $prompt The tone prompt text |
| 14 | * @property \Carbon\Carbon|null $created_at |
| 15 | * @property \Carbon\Carbon|null $updated_at |
| 16 | */ |
| 17 | class PromptToneResource extends JsonResource |
| 18 | { |
| 19 | /** |
| 20 | * Transform the resource into an array. |
| 21 | * |
| 22 | * @return array<string, mixed> |
| 23 | */ |
| 24 | public function toArray(Request $request): array |
| 25 | { |
| 26 | return [ |
| 27 | 'id' => (string) $this->_id, |
| 28 | 'name' => $this->name, |
| 29 | 'prompt' => $this->prompt, |
| 30 | 'created_at' => $this->created_at?->timestamp, |
| 31 | 'updated_at' => $this->updated_at?->timestamp, |
| 32 | ]; |
| 33 | } |
| 34 | } |