| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace App\Http\Resources;
- use Carbon\Carbon;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
- use Illuminate\Http\Resources\Json\JsonResource;
- use Illuminate\Support\Facades\Storage;
- class StudentResource extends JsonResource
- {
- public function toArray(Request $request): array
- {
- return [
- 'id' => $this->id,
- 'unit_id' => $this->unit_id,
- 'name' => $this->name,
- 'birth_date' => $this->birth_date?->format('Y-m-d'),
- 'document_number' => $this->document_number,
- 'gender' => $this->gender,
- 'email' => $this->email,
- 'phone' => $this->phone,
- 'postal_code' => $this->postal_code,
- 'street' => $this->street,
- 'address_number' => $this->address_number,
- 'neighborhood' => $this->neighborhood,
- 'city_id' => $this->city_id,
- 'state_id' => $this->state_id,
- 'complement' => $this->complement,
- 'payer_name' => $this->payer_name,
- 'how_did_you_know_us' => $this->how_did_you_know_us,
- 'notes' => $this->notes,
- 'photo_url' => $this->photo_url ? Storage::url($this->photo_url) : null,
- 'status' => $this->status,
- 'created_at' => Carbon::parse($this->created_at)->format('Y-m-d H:i:s'),
- 'updated_at' => Carbon::parse($this->updated_at)->format('Y-m-d H:i:s'),
- ];
- }
- public static function collection($resource): AnonymousResourceCollection
- {
- return parent::collection($resource);
- }
- }
|