1
0

big update base struktur tahap 1

This commit is contained in:
Wian Drs
2026-07-27 16:24:09 +07:00
parent 2b3592c4c2
commit 1dd02baa72
169 changed files with 24405 additions and 977 deletions
@@ -0,0 +1,23 @@
<?php
namespace App\Http\Requests\Wilayah;
use Illuminate\Foundation\Http\FormRequest;
class AlamatLengkapRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'desa_id' => ['nullable', 'required_without_all:kecamatan_id,kabupaten_id,provinsi_id', 'integer', 'exists:wilayah_desa,id'],
'kecamatan_id' => ['nullable', 'required_without_all:desa_id,kabupaten_id,provinsi_id', 'integer', 'exists:wilayah_kecamatan,id'],
'kabupaten_id' => ['nullable', 'required_without_all:desa_id,kecamatan_id,provinsi_id', 'integer', 'exists:wilayah_kabupaten,id'],
'provinsi_id' => ['nullable', 'required_without_all:desa_id,kecamatan_id,kabupaten_id', 'integer', 'exists:wilayah_provinsi,id'],
];
}
}
@@ -0,0 +1,36 @@
<?php
namespace App\Http\Requests\Wilayah;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class IndexWilayahRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
/** Pencarian berdasarkan kode atau nama wilayah. */
'search' => ['nullable', 'string', 'max:255'],
/** Filter kabupaten berdasarkan provinsi. */
'provinsi_id' => ['nullable', 'integer', 'exists:wilayah_provinsi,id'],
/** Filter kecamatan berdasarkan kabupaten. */
'kabupaten_id' => ['nullable', 'integer', 'exists:wilayah_kabupaten,id'],
/** Filter desa berdasarkan kecamatan. */
'kecamatan_id' => ['nullable', 'integer', 'exists:wilayah_kecamatan,id'],
/** Nomor halaman. */
'page' => ['nullable', 'integer', 'min:1'],
/** Jumlah data per halaman, maksimal 100. */
'per_page' => ['nullable', 'integer', 'min:1', 'max:100'],
/** Kolom pengurutan data. */
'sort_by' => ['nullable', Rule::in(['id', 'kode', 'nama', 'created_at'])],
/** Arah pengurutan data. */
'sort_direction' => ['nullable', Rule::in(['asc', 'desc'])],
];
}
}
@@ -0,0 +1,21 @@
<?php
namespace App\Http\Requests\Wilayah;
use Illuminate\Foundation\Http\FormRequest;
class LookupWilayahRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
/** Pencarian opsional berdasarkan kode atau nama wilayah. */
'search' => ['nullable', 'string', 'max:100'],
];
}
}
@@ -0,0 +1,40 @@
<?php
namespace App\Http\Requests\Wilayah;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreWilayahRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
$tingkat = $this->route('tingkat');
$table = "wilayah_{$tingkat}";
return [
'kode' => ['required', 'string', 'max:20', Rule::unique($table, 'kode')],
'nama' => ['required', 'string', 'max:255'],
'provinsi_id' => [
Rule::requiredIf($tingkat === 'kabupaten'),
'integer',
'exists:wilayah_provinsi,id',
],
'kabupaten_id' => [
Rule::requiredIf($tingkat === 'kecamatan'),
'integer',
'exists:wilayah_kabupaten,id',
],
'kecamatan_id' => [
Rule::requiredIf($tingkat === 'desa'),
'integer',
'exists:wilayah_kecamatan,id',
],
];
}
}
@@ -0,0 +1,52 @@
<?php
namespace App\Http\Requests\Wilayah;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateWilayahRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
$tingkat = $this->route('tingkat');
$table = "wilayah_{$tingkat}";
return [
'kode' => [
'sometimes',
'required',
'string',
'max:20',
Rule::unique($table, 'kode')->ignore($this->route('wilayah')),
],
'nama' => ['sometimes', 'required', 'string', 'max:255'],
'provinsi_id' => [
Rule::excludeIf($tingkat !== 'kabupaten'),
'sometimes',
'required',
'integer',
'exists:wilayah_provinsi,id',
],
'kabupaten_id' => [
Rule::excludeIf($tingkat !== 'kecamatan'),
'sometimes',
'required',
'integer',
'exists:wilayah_kabupaten,id',
],
'kecamatan_id' => [
Rule::excludeIf($tingkat !== 'desa'),
'sometimes',
'required',
'integer',
'exists:wilayah_kecamatan,id',
],
];
}
}