Merge branch 'staging' of https://git.putrakuningan.com/daengdeni/lpj into tender
This commit is contained in:
@@ -63,6 +63,7 @@
|
||||
public function update(PemilikJaminanRequest $request, $id, $pemilik)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
$pemilik = PemilikJaminan::find($pemilik);
|
||||
@@ -88,6 +89,7 @@
|
||||
$districts = District::where('city_code', $pemilik->city_code)->get();
|
||||
$villages = Village::where('district_code', $pemilik->district_code)->get();
|
||||
$hubunganPemilik = HubunganPemilikJaminan::all();
|
||||
$detailSertifikat = $pemilik->detail_sertifikat;
|
||||
|
||||
return view(
|
||||
'lpj::pemilik_jaminan.form',
|
||||
@@ -99,6 +101,7 @@
|
||||
'villages',
|
||||
'hubunganPemilik',
|
||||
'pemilik',
|
||||
'detailSertifikat'
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Modules\Lpj\Rules\UniqueCifExceptZero;
|
||||
use Modules\Lpj\Rules\UniqueExcept;
|
||||
|
||||
class DebitureRequest extends FormRequest
|
||||
{
|
||||
|
||||
@@ -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),
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ class PemilikJaminan extends Base
|
||||
'status',
|
||||
'authorized_at',
|
||||
'authorized_status',
|
||||
'authorized_by'
|
||||
'authorized_by',
|
||||
'detail_sertifikat',
|
||||
];
|
||||
|
||||
public function province()
|
||||
|
||||
@@ -1,25 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Rules;
|
||||
namespace Modules\Lpj\Rules;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
|
||||
class UniqueCifExceptZero implements ValidationRule
|
||||
{
|
||||
public function __construct($id = null)
|
||||
class UniqueCifExceptZero implements ValidationRule
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
protected $id;
|
||||
|
||||
public function validate($attribute, $value, $fail): void
|
||||
{
|
||||
if (Debiture::where($attribute, $value)
|
||||
->where('id', '!=', $this->id)
|
||||
->where($attribute, '!=', '0000000000')
|
||||
->exists()) {
|
||||
$fail('The :attribute field must be uniquse.'.$this->id);
|
||||
public function __construct($id = null)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the validation rule.
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail)
|
||||
: void {
|
||||
if ($value !== '0000000000' && $value !== null && Debiture::query()->where($attribute, $value)->when(
|
||||
$this->id,
|
||||
function ($query) {
|
||||
$query->where('id', '!=', $this->id);
|
||||
},
|
||||
)->exists()) {
|
||||
$fail('The :attribute field must be unique.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user