Update Module Permohonan

- Update Automaticly get branch id by user login
- change static status permohonan to dynamic and database base
- update create permohonan, update selection debiture to table base
This commit is contained in:
Daeng Deni Mardaeni
2024-09-03 13:41:05 +07:00
parent 3c59943a08
commit be47e0678a
8 changed files with 266 additions and 78 deletions

View File

@@ -2,6 +2,7 @@
namespace Modules\Lpj\Http\Requests;
use Haruncpi\LaravelIdGenerator\IdGenerator;
use Illuminate\Foundation\Http\FormRequest;
class JenisJaminanRequest extends FormRequest
@@ -12,16 +13,10 @@
public function rules()
: array
{
$rules = [
return [
'code' => 'required|max:5',
'name' => 'required|max:255',
];
if ($this->method() == 'PUT') {
$rules['code'] = 'required|max:50|unique:jenis_jaminan,code,' . $this->id;
} else {
$rules['code'] = 'required|max:50|unique:jenis_jaminan,code';
}
return $rules;
}
/**
@@ -32,4 +27,16 @@
{
return true;
}
public function prepareForValidation()
: void
{
if ($this->method() == 'POST') {
$this->merge([
'code' => IdGenerator::generate(
['table' => 'jenis_jaminan', 'length' => 5, 'prefix' => 'JJ', 'field' => 'code'],
),
]);
}
}
}

View File

@@ -40,10 +40,11 @@
if (!$this->id) {
$this->merge([
'nomor_registrasi' => IdGenerator::generate(
['table' => 'permohonan', 'length' => 10, 'prefix'=>'REG', 'field' => 'nomor_registrasi'],
['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,
]);
}
}