| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Http\Resources;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\JsonResource;
- class ScheduleResource extends JsonResource
- {
- public function toArray(Request $request): array
- {
- return [
- 'id' => $this->id,
- 'client_id' => $this->client_id,
- 'client_name' => $this->client?->user?->name,
- 'provider_id' => $this->provider_id,
- 'provider_name' => $this->provider?->user?->name,
- 'address_id' => $this->address_id,
- 'address_full' => $this->address ?
- "{$this->address->address}" .
- ($this->address->complement ? " - {$this->address->complement}" : '') .
- " , {$this->address->city->name}/{$this->address->state->code}"
- : null,
- 'address' => new AddressResource($this->whenLoaded('address')),
- 'date' => $this->date?->format('Y-m-d'),
- 'period_type' => $this->period_type,
- 'schedule_type' => $this->schedule_type,
- 'start_time' => $this->start_time,
- 'end_time' => $this->end_time,
- 'status' => $this->status,
- 'total_amount' => $this->total_amount,
- 'code' => $this->code,
- 'code_verified' => $this->code_verified,
- 'created_at' => $this->created_at?->toISOString(),
- 'updated_at' => $this->updated_at?->toISOString(),
- 'deleted_at' => $this->deleted_at?->toISOString(),
- ];
- }
- }
|