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:
@@ -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),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'];
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -10,51 +10,83 @@
|
||||
<form action="{{ route('basicdata.jenis-legalitas-jaminan.update', $jenisLegalitasJaminan->id) }}" method="POST">
|
||||
<input type="hidden" name="id" value="{{ $jenisLegalitasJaminan->id }}">
|
||||
@method('PUT')
|
||||
@else
|
||||
<form method="POST" action="{{ route('basicdata.jenis-legalitas-jaminan.store') }}">
|
||||
@endif
|
||||
@csrf
|
||||
<div class="card pb-2.5">
|
||||
<div class="card-header" id="basic_settings">
|
||||
<h3 class="card-title">
|
||||
{{ isset($jenisLegalitasJaminan->id) ? 'Edit' : 'Tambah' }} Jenis Legalitas Jaminan
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('basicdata.jenis-legalitas-jaminan.index') }}" class="btn btn-xs btn-info"><i class="ki-filled ki-exit-left"></i> Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body grid gap-5">
|
||||
@if(isset($jenisLegalitasJaminan->id))
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Code
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input readonly class="input border-warning bg-warning-light @error('code') border-danger bg-danger-light @enderror" type="text" name="code" value="{{ $jenisLegalitasJaminan->code ?? '' }}">
|
||||
@error('code')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Name
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('name') border-danger bg-danger-light @enderror" type="text" name="name" value="{{ $jenisLegalitasJaminan->name ?? '' }}">
|
||||
@error('name')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@else
|
||||
<form method="POST" action="{{ route('basicdata.jenis-legalitas-jaminan.store') }}">
|
||||
@endif
|
||||
@csrf
|
||||
<div class="card pb-2.5">
|
||||
<div class="card-header" id="basic_settings">
|
||||
<h3 class="card-title">
|
||||
{{ isset($jenisLegalitasJaminan->id) ? 'Edit' : 'Tambah' }} Jenis Legalitas Jaminan
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('basicdata.jenis-legalitas-jaminan.index') }}" class="btn btn-xs btn-info"><i class="ki-filled ki-exit-left"></i> Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body grid gap-5">
|
||||
@if(isset($jenisLegalitasJaminan->id))
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Code
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input readonly class="input border-warning bg-warning-light @error('code') border-danger bg-danger-light @enderror" type="text" name="code" value="{{ $jenisLegalitasJaminan->code ?? '' }}">
|
||||
@error('code')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Name
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('name') border-danger bg-danger-light @enderror" type="text" name="name" value="{{ $jenisLegalitasJaminan->name ?? '' }}">
|
||||
@error('name')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</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">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user