From ec6cb8e09f0a925c697ec3bbcac31c4eea4e366d Mon Sep 17 00:00:00 2001 From: Daeng Deni Mardaeni Date: Mon, 4 Nov 2024 15:59:59 +0700 Subject: [PATCH] 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. --- .../Requests/JenisLegalitasJaminanRequest.php | 12 +- app/Models/JenisLegalitasJaminan.php | 2 +- ...3_update_jenis_legalitas_jaminan_table.php | 30 +++++ .../jenis_legalitas_jaminan/create.blade.php | 124 +++++++++++------- 4 files changed, 116 insertions(+), 52 deletions(-) create mode 100644 database/migrations/2024_11_04_080443_update_jenis_legalitas_jaminan_table.php diff --git a/app/Http/Requests/JenisLegalitasJaminanRequest.php b/app/Http/Requests/JenisLegalitasJaminanRequest.php index 1d5d98c..82fb205 100644 --- a/app/Http/Requests/JenisLegalitasJaminanRequest.php +++ b/app/Http/Requests/JenisLegalitasJaminanRequest.php @@ -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), ]); } } diff --git a/app/Models/JenisLegalitasJaminan.php b/app/Models/JenisLegalitasJaminan.php index 2d7567c..dd8f840 100644 --- a/app/Models/JenisLegalitasJaminan.php +++ b/app/Models/JenisLegalitasJaminan.php @@ -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']; } diff --git a/database/migrations/2024_11_04_080443_update_jenis_legalitas_jaminan_table.php b/database/migrations/2024_11_04_080443_update_jenis_legalitas_jaminan_table.php new file mode 100644 index 0000000..e8e93e6 --- /dev/null +++ b/database/migrations/2024_11_04_080443_update_jenis_legalitas_jaminan_table.php @@ -0,0 +1,30 @@ +string('custom_field')->nullable()->after('slug'); + $table->string('custom_field_type')->nullable()->after('custom_field'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('jenis_legalitas_jaminan', function (Blueprint $table) { + $table->dropColumn('custom_field'); + $table->dropColumn('custom_field_type'); + }); + } +}; diff --git a/resources/views/jenis_legalitas_jaminan/create.blade.php b/resources/views/jenis_legalitas_jaminan/create.blade.php index 5b586a9..919892a 100644 --- a/resources/views/jenis_legalitas_jaminan/create.blade.php +++ b/resources/views/jenis_legalitas_jaminan/create.blade.php @@ -10,51 +10,83 @@
@method('PUT') - @else - - @endif - @csrf -
-
-

- {{ isset($jenisLegalitasJaminan->id) ? 'Edit' : 'Tambah' }} Jenis Legalitas Jaminan -

-
- Back -
-
-
- @if(isset($jenisLegalitasJaminan->id)) -
- -
- - @error('code') - {{ $message }} - @enderror -
-
- @endif -
- -
- - @error('name') - {{ $message }} - @enderror -
-
-
- -
-
-
-
+ @else +
+ @endif + @csrf +
+
+

+ {{ isset($jenisLegalitasJaminan->id) ? 'Edit' : 'Tambah' }} Jenis Legalitas Jaminan +

+
+ Back +
+
+
+ @if(isset($jenisLegalitasJaminan->id)) +
+ +
+ + @error('code') + {{ $message }} + @enderror +
+
+ @endif +
+ +
+ + @error('name') + {{ $message }} + @enderror +
+
+ + +
+ +
+ + @error('custom_field') + {{ $message }} + @enderror +
+
+ + +
+ +
+ + @error('custom_field_type') + {{ $message }} + @enderror +
+
+ +
+ +
+
+
+
@endsection