This commit is contained in:
Saufi
2026-06-03 08:51:22 +08:00
commit a14d43fe34
347 changed files with 38197 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Http\Requests\Admin\Management;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreRepresentativeRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user()?->hasRole('Admin') === true;
}
protected function prepareForValidation(): void
{
$this->merge([
'ic_number' => blank($this->input('ic_number')) ? null : preg_replace('/\D+/', '', (string) $this->input('ic_number')),
'saluran_mengundi_id' => blank($this->input('saluran_mengundi_id')) ? null : $this->input('saluran_mengundi_id'),
]);
}
/**
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'type' => ['required', Rule::in(['police', 'kkm', 'jkm'])],
'election_id' => ['required', 'integer', 'exists:elections,id'],
'pusat_mengundi_id' => ['required', 'integer', 'exists:pusat_mengundis,id'],
'saluran_mengundi_id' => ['nullable', 'integer', 'exists:saluran_mengundis,id'],
'name' => ['required', 'string', 'max:255'],
'ic_number' => ['nullable', 'digits:12'],
'phone_number' => ['nullable', 'string', 'max:30'],
'rank' => ['nullable', 'string', 'max:255'],
'station' => ['nullable', 'string', 'max:255'],
'agency' => ['nullable', 'string', 'max:255'],
'notes' => ['nullable', 'string', 'max:2000'],
'note' => ['nullable', 'string', 'max:2000'],
];
}
}