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

@@ -18,6 +18,8 @@
'code' => 'required|max:6', 'code' => 'required|max:6',
'name' => 'required|max:255', 'name' => 'required|max:255',
'slug' => 'required|max:255', 'slug' => 'required|max:255',
'custom_field' => 'nullable|max:255',
'custom_field_type' => 'nullable|max:255',
]; ];
} }

View File

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

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('jenis_legalitas_jaminan', function (Blueprint $table) {
$table->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');
});
}
};

View File

@@ -48,6 +48,38 @@
@enderror @enderror
</div> </div>
</div> </div>
<!-- Tambahkan inputan custom_field -->
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">
Custom Field
</label>
<div class="flex flex-wrap items-baseline w-full">
<input class="input @error('custom_field') border-danger bg-danger-light @enderror" type="text" name="custom_field" value="{{ $jenisLegalitasJaminan->custom_field ?? '' }}">
@error('custom_field')
<em class="alert text-danger text-sm">{{ $message }}</em>
@enderror
</div>
</div>
<!-- Tambahkan inputan custom_field_type -->
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">
Custom Field Type
</label>
<div class="flex flex-wrap items-baseline w-full">
<select class="input tomselect @error('custom_field_type') border-danger bg-danger-light @enderror" name="custom_field_type">
<option value="">Pilih Tipe</option>
<option value="text" {{ (isset($jenisLegalitasJaminan) && $jenisLegalitasJaminan->custom_field_type == 'text') ? 'selected' : '' }}>Text</option>
<option value="number" {{ (isset($jenisLegalitasJaminan) && $jenisLegalitasJaminan->custom_field_type == 'number') ? 'selected' : '' }}>Number</option>
<option value="date" {{ (isset($jenisLegalitasJaminan) && $jenisLegalitasJaminan->custom_field_type == 'date') ? 'selected' : '' }}>Date</option>
</select>
@error('custom_field_type')
<em class="alert text-danger text-sm">{{ $message }}</em>
@enderror
</div>
</div>
<div class="flex justify-end"> <div class="flex justify-end">
<button type="submit" class="btn btn-primary"> <button type="submit" class="btn btn-primary">
Save Save