Add custom fields to JenisLegalitasJaminan

Added `custom_field` and `custom_field_type` columns to the `jenis_legalitas_jaminan` table. Updated model, migration, and request files to handle these new fields, ensuring they are optional and have a maximum length of 255 characters.
This commit is contained in:
Daeng Deni Mardaeni
2024-11-04 15:59:59 +07:00
parent 2908a21454
commit ec6cb8e09f
4 changed files with 116 additions and 52 deletions

View File

@@ -15,9 +15,11 @@
: array
{
return [
'code' => 'required|max:6',
'name' => 'required|max:255',
'slug' => 'required|max:255',
'code' => 'required|max:6',
'name' => 'required|max:255',
'slug' => 'required|max:255',
'custom_field' => 'nullable|max:255',
'custom_field_type' => 'nullable|max:255',
];
}
@@ -32,7 +34,7 @@
public function prepareForValidation()
{
if($this->method() == 'POST' && $this->code == null) {
if ($this->method() == 'POST' && $this->code == null) {
$this->merge([
'code' => IdGenerator::generate(
['table' => 'jenis_legalitas_jaminan', 'length' => 6, 'prefix' => 'JLJ', 'field' => 'code'],
@@ -41,7 +43,7 @@
]);
} else {
$this->merge([
'slug' => Str::slug($this->name),
'slug' => Str::slug($this->name),
]);
}
}

View File

@@ -7,5 +7,5 @@
class JenisLegalitasJaminan extends Base
{
protected $table = 'jenis_legalitas_jaminan';
protected $fillable = ['code', 'name','slug'];
protected $fillable = ['code', 'name','slug','custom_field','custom_field_type'];
}