Add support for multiple detail sertifikat
Enhanced the request validation, model, and Blade template to support multiple detail sertifikat entries, which are now encoded in JSON format. Additionally, added a dynamic form for entry, including delete functionality for each sertifikat entry.
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
'address' => 'nullable|string',
|
||||
'postal_code' => 'nullable|string|max:10',
|
||||
'status' => 'nullable|boolean',
|
||||
'detail_sertifikat' => 'nullable|string|max:255',
|
||||
];
|
||||
|
||||
//$rules['nomor_id'] = 'nullable|max:16|unique:pemilik_jaminan,nomor_id,debiture_id,' . $this->debiture_id;
|
||||
@@ -41,4 +42,26 @@
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function prepareForValidation() {
|
||||
|
||||
$detailSertifikat = [];
|
||||
$names = $this->input('detail_sertifikat.name', []);
|
||||
$nomorIds = $this->input('detail_sertifikat.nomor_id', []);
|
||||
|
||||
foreach ($names as $index => $name) {
|
||||
if (isset($nomorIds[$index])) {
|
||||
$detailSertifikat[] = [
|
||||
'name' => $name,
|
||||
'nomor_id' => $nomorIds[$index]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$this->merge([
|
||||
'detail_sertifikat' => json_encode($detailSertifikat),
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user