Merge pull request 'feat(branch): add 'is_dalam_kota' field to Branch form and validation rules' (#2) from shola into master

Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
2025-12-11 15:32:06 +07:00
2 changed files with 115 additions and 75 deletions

View File

@@ -28,6 +28,7 @@
'authorized_at' => 'nullable|datetime',
'authorized_status' => 'nullable|string|max:1',
'authorized_by' => 'nullable|exists:users,id',
'is_dalam_kota' => 'nullable|in:0,1',
];
if ($this->method() == 'PUT') {

View File

@@ -20,7 +20,8 @@
{{ isset($branch->id) ? 'Edit' : 'Tambah' }} Branch
</h3>
<div class="flex items-center gap-2">
<a href="{{ route('basicdata.branch.index') }}" class="btn btn-xs btn-info"><i class="ki-filled ki-exit-left"></i> Back</a>
<a href="{{ route('basicdata.branch.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">
@@ -29,7 +30,8 @@
Code
</label>
<div class="flex flex-wrap items-baseline w-full">
<input class="input @error('code') border-danger bg-danger-light @enderror" type="text" name="code" value="{{ $branch->code ?? '' }}">
<input class="input @error('code') border-danger bg-danger-light @enderror" type="text"
name="code" value="{{ $branch->code ?? '' }}">
@error('code')
<em class="alert text-danger text-sm">{{ $message }}</em>
@enderror
@@ -40,12 +42,48 @@
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="{{ $branch->name ?? '' }}">
<input class="input @error('name') border-danger bg-danger-light @enderror" type="text"
name="name" value="{{ $branch->name ?? '' }}">
@error('name')
<em class="alert text-danger text-sm">{{ $message }}</em>
@enderror
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">
Branch Type
</label>
<div class="flex flex-wrap items-baseline w-full">
@php
$selectedDalamKota = old(
'is_dalam_kota',
isset($branch->is_dalam_kota) ? $branch->is_dalam_kota : '',
);
@endphp
<select class="input @error('is_dalam_kota') border-danger bg-danger-light @enderror"
name="is_dalam_kota" id="is_dalam_kota">
<!-- DEFAULT PILIHAN SAAT CREATE -->
<option value="">-- Select Branch Location --</option>
<option value="1" {{ $selectedDalamKota == 1 ? 'selected' : '' }}>
Dalam Kota
</option>
<option value="0" {{ $selectedDalamKota == 0 ? 'selected' : '' }}>
Luar Kota
</option>
</select>
@error('is_dalam_kota')
<em class="alert text-danger text-sm">{{ $message }}</em>
@enderror
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">
Parent Branch
@@ -55,7 +93,8 @@
<option value="">-- Select Parent Branch --</option>
@foreach ($branches as $parentBranch)
@if (!isset($branch->id) || $parentBranch->id != $branch->id)
<option value="{{ $parentBranch->id }}" {{ (isset($branch->parent_id) && $branch->parent_id == $parentBranch->id) ? 'selected' : '' }}>
<option value="{{ $parentBranch->id }}"
{{ isset($branch->parent_id) && $branch->parent_id == $parentBranch->id ? 'selected' : '' }}>
{{ $parentBranch->code }} - {{ $parentBranch->name }}
</option>
@endif