database-pertani-web/app/Http/Resources/ProfileResource.php

37 lines
1.1 KiB
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Http\Resources\Wilayah\DesaKelurahanResource;
use App\Http\Resources\UserResource;
class ProfileResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'user_id' => $this->user_id,
'nama' => $this->nama,
'email' => $this->email,
'telepon' => $this->telepon,
'alamat' => $this->alamat,
'ktp' => $this->ktp,
'kk' => $this->kk,
// 'file_ktp' => $this->file_ktp,
// 'file_kk' => $this->file_kk,
'desa_kelurahan_id' => $this->desa_kelurahan_id,
'desa_kelurahan' => $this->desaKelurahan ? new DesaKelurahanResource($this->desaKelurahan) : null,
'user' => $this->user ? new UserResource($this->user) : null,
];
}
}