Files
lpj/app/Http/Requests/PermohonanRequest.php
Daeng Deni Mardaeni 4fc1088964 Perbarui validasi permohonan dan penyesuaian form
Jadikan `branch_id` nullable di PermohonanRequest.php untuk menyelaraskan dengan requirement terbaru. Hapus kode yang tidak diperlukan di PermohonanController.php untuk meningkatkan keterbacaan. Optimalisasi form di form.blade.php dengan memperbaiki kesalahan penulisan dan menyederhanakan penanda kondisi pada elemen form. Tambahkan input hidden untuk `id` saat update permohonan.
2024-11-06 15:25:09 +07:00

57 lines
2.0 KiB
PHP

<?php
namespace Modules\Lpj\Http\Requests;
use daengdeni\LaravelIdGenerator\IdGenerator;
use Illuminate\Foundation\Http\FormRequest;
class PermohonanRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*/
public function rules()
: array
{
$rules = [
'nomor_registrasi' => 'nullable|string|max:10',
'tanggal_permohonan' => 'nullable|date',
'user_id' => 'nullable|exists:users,id',
'branch_id' => 'nullable|exists:branches,id',
'tujuan_penilaian_id' => 'required|exists:tujuan_penilaian,id',
'debiture_id' => 'required|exists:debitures,id',
'status' => 'nullable|string',
'jenis_fasilitas_kredit_id' => 'required|exists:jenis_fasilitas_kredit,id',
'nilai_plafond_id' => 'required|exists:nilai_plafond,id',
'status_bayar' => 'required|string',
'nilai_njop' => 'nullable|numeric'
];
return $rules;
}
/**
* Determine if the user is authorized to make this request.
*/
public function authorize()
: bool
{
return true;
}
public function prepareForValidation()
{
if (!$this->id) {
$this->merge([
'nomor_registrasi' => IdGenerator::generate(
['table' => 'permohonan', 'length' => 10, 'prefix' => 'REG', 'field' => 'nomor_registrasi'],
),
'tanggal_permohonan' => date('Y-m-d'),
'user_id' => auth()->user()->id,
'branch_id' => auth()->user()->branch_id,
'status' => 'order'
]);
}
}
}