Program api
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Core;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
use App\Http\Resources\Wilayah\ProvinsiResource;
|
||||
use App\Http\Resources\Wilayah\KabupatenKotaResource;
|
||||
use App\Http\Resources\Wilayah\KecamatanResource;
|
||||
use App\Http\Resources\Wilayah\DesaKelurahanResource;
|
||||
|
||||
class ProgramLokasiResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'program_id' => $this->program_id,
|
||||
'provinsi_id' => $this->provinsi_id,
|
||||
'kabupaten_kota_id' => $this->kabupaten_kota_id,
|
||||
'kecamatan_id' => $this->kecamatan_id,
|
||||
'desa_kelurahan_id' => $this->desa_kelurahan_id,
|
||||
'default' => $this->default,
|
||||
'provinsi' => $this->provinsi ? new ProvinsiResource($this->provinsi) : null,
|
||||
'kabupatenKota' => $this->kabupatenKota ? new KabupatenKotaResource($this->kabupatenKota) : null,
|
||||
'kecamatan' => $this->kecamatan ? new KecamatanResource($this->kecamatan) : null,
|
||||
'desaKelurahan' => $this->desaKelurahan ? new DesaKelurahanResource($this->desaKelurahan) : null,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user