update api scramble telescope

This commit is contained in:
2026-03-17 09:58:11 +07:00
parent 3a9f3bd813
commit 106283903e
21 changed files with 797 additions and 61 deletions
+36
View File
@@ -0,0 +1,36 @@
<?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,
];
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class UserResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'email' => $this->email,
'email_verified_at' => $this->email_verified_at,
'role' => $this->role,
];
}
}
@@ -0,0 +1,24 @@
<?php
namespace App\Http\Resources\Wilayah;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class DesaKelurahanResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'nama' => $this->nama,
'kode' => $this->kode,
'kecamatan' => $this->kecamatan ? new KecamatanResource($this->kecamatan) : null,
];
}
}
@@ -0,0 +1,26 @@
<?php
namespace App\Http\Resources\Wilayah;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Http\Resources\Wilayah\ProvinsiResource;
class KabupatenKotaResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'nama' => $this->nama,
'kode' => $this->kode,
'provinsi' => $this->provinsi ? new ProvinsiResource($this->provinsi) : null,
];
}
}
@@ -0,0 +1,26 @@
<?php
namespace App\Http\Resources\Wilayah;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Http\Resources\Wilayah\KabupatenKotaResource;
class KecamatanResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'nama' => $this->nama,
'kode' => $this->kode,
'kabupatenKota' => $this->kabupatenKota ? new KabupatenKotaResource($this->kabupatenKota) : null,
];
}
}
@@ -0,0 +1,23 @@
<?php
namespace App\Http\Resources\Wilayah;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class ProvinsiResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'nama' => $this->nama,
'kode' => $this->kode,
];
}
}