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,35 @@
<?php
namespace App\Http\Requests\User;
use App\Enums\UserAccessLevel;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class IndexUserRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
/** Kata kunci untuk mencari nama, username, email, atau nomor WhatsApp. */
'search' => ['nullable', 'string', 'max:255'],
/** Filter status akun user. */
'status' => ['nullable', Rule::in(['active', 'inactive', 'suspended'])],
/** Filter level akses user. */
'access_level' => ['nullable', Rule::enum(UserAccessLevel::class)],
/** Nomor halaman yang ingin diambil. */
'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', 'name', 'username', 'email', 'whatsapp_number', 'access_level', 'status', 'created_at'])],
/** Arah pengurutan data. */
'sort_direction' => ['nullable', Rule::in(['asc', 'desc'])],
];
}
}
@@ -0,0 +1,66 @@
<?php
namespace App\Http\Requests\User;
use App\Enums\UserAccessLevel;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreUserRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'username' => ['nullable', 'string', 'max:255', 'unique:users,username'],
'email' => ['required', 'email', 'max:255', 'unique:users,email'],
'whatsapp_number' => ['nullable', 'string', 'max:20'],
'password' => ['required', 'string', 'min:8'],
'is_master' => ['nullable', 'boolean'],
'access_level' => ['nullable', Rule::enum(UserAccessLevel::class)],
'status' => ['required', Rule::in(['active', 'inactive', 'suspended'])],
'user_profile' => ['nullable', 'array'],
'user_profile.nik' => ['nullable', 'string', 'max:30'],
'user_profile.address' => ['nullable', 'string'],
'user_profile.provinsi_id' => ['nullable', 'integer', 'exists:wilayah_provinsi,id'],
'user_profile.kabupaten_id' => [
'nullable',
'integer',
Rule::exists('wilayah_kabupaten', 'id')->where(
'provinsi_id',
$this->input('user_profile.provinsi_id')
),
],
'user_profile.kecamatan_id' => [
'nullable',
'integer',
Rule::exists('wilayah_kecamatan', 'id')->where(
'kabupaten_id',
$this->input('user_profile.kabupaten_id')
),
],
'user_profile.desa_id' => [
'nullable',
'integer',
Rule::exists('wilayah_desa', 'id')->where(
'kecamatan_id',
$this->input('user_profile.kecamatan_id')
),
],
'user_tenants' => ['nullable', 'array'],
'user_tenants.*.tenant_id' => ['required_with:user_tenants', 'integer', 'exists:tenants,id'],
'user_tenants.*.is_default' => ['nullable', 'boolean'],
'user_menu_groups' => ['nullable', 'array'],
'user_menu_groups.*.menu_group_id' => ['required_with:user_menu_groups', 'integer', 'exists:menu_groups,id'],
'user_menu_groups.*.tenant_id' => ['nullable', 'integer', 'exists:tenants,id'],
];
}
}
@@ -0,0 +1,79 @@
<?php
namespace App\Http\Requests\User;
use App\Enums\UserAccessLevel;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateUserRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
$userId = $this->route('user')?->id ?? $this->route('user');
return [
'name' => ['sometimes', 'required', 'string', 'max:255'],
'username' => [
'nullable',
'string',
'max:255',
Rule::unique('users', 'username')->ignore($userId),
],
'email' => [
'sometimes',
'required',
'email',
'max:255',
Rule::unique('users', 'email')->ignore($userId),
],
'whatsapp_number' => ['nullable', 'string', 'max:20'],
'password' => ['nullable', 'string', 'min:8'],
'is_master' => ['nullable', 'boolean'],
'access_level' => ['sometimes', 'required', Rule::enum(UserAccessLevel::class)],
'status' => ['sometimes', 'required', Rule::in(['active', 'inactive', 'suspended'])],
'user_profile' => ['nullable', 'array'],
'user_profile.nik' => ['nullable', 'string', 'max:30'],
'user_profile.address' => ['nullable', 'string'],
'user_profile.provinsi_id' => ['nullable', 'integer', 'exists:wilayah_provinsi,id'],
'user_profile.kabupaten_id' => [
'nullable',
'integer',
Rule::exists('wilayah_kabupaten', 'id')->where(
'provinsi_id',
$this->input('user_profile.provinsi_id')
),
],
'user_profile.kecamatan_id' => [
'nullable',
'integer',
Rule::exists('wilayah_kecamatan', 'id')->where(
'kabupaten_id',
$this->input('user_profile.kabupaten_id')
),
],
'user_profile.desa_id' => [
'nullable',
'integer',
Rule::exists('wilayah_desa', 'id')->where(
'kecamatan_id',
$this->input('user_profile.kecamatan_id')
),
],
'user_tenants' => ['nullable', 'array'],
'user_tenants.*.tenant_id' => ['required_with:user_tenants', 'integer', 'exists:tenants,id'],
'user_tenants.*.is_default' => ['nullable', 'boolean'],
'user_menu_groups' => ['nullable', 'array'],
'user_menu_groups.*.menu_group_id' => ['required_with:user_menu_groups', 'integer', 'exists:menu_groups,id'],
'user_menu_groups.*.tenant_id' => ['nullable', 'integer', 'exists:tenants,id'],
];
}
}