Compare commits
4 Commits
v1.0.0
...
08582a2aa3
| Author | SHA1 | Date | |
|---|---|---|---|
| 08582a2aa3 | |||
|
|
0526a1bb05 | ||
| 9845b01b0e | |||
|
|
fec8dc083c |
@@ -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') {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name',
|
||||
'is_dalam_kota',
|
||||
'address',
|
||||
'mnemonic',
|
||||
'customer_company',
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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('branches', function (Blueprint $table) {
|
||||
$table->boolean('is_dalam_kota')->default(true)->after('name');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('branches', function (Blueprint $table) {
|
||||
$table->dropColumn('is_dalam_kota');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -59,7 +59,8 @@
|
||||
['code' => 'PKR', 'name' => 'Pakistani Rupee', 'symbol' => '₨', 'decimal_places' => 2, 'status' => true, 'created_at' => $now, 'updated_at' => $now],
|
||||
];
|
||||
|
||||
DB::table('currencies')->truncate();
|
||||
// DB::table('currencies')->truncate();
|
||||
DB::table('currencies')->delete();
|
||||
DB::table('currencies')->insert($currencies);
|
||||
}
|
||||
}
|
||||
|
||||
54
database/seeders/UpdateBranchesIsDalamKotaSeeder.php
Normal file
54
database/seeders/UpdateBranchesIsDalamKotaSeeder.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Basicdata\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Modules\Basicdata\Models\Branch;
|
||||
|
||||
class UpdateBranchesIsDalamKotaSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$codes = [
|
||||
'0005','0012','0250','0016','0018','0279','0092','0022','0251',
|
||||
'0029','0270','0096','0109','0098','2005','0008','0028','0015',
|
||||
'0006','0090','0009','0023','0020','0099','0003','0010','0002',
|
||||
'0273','0011','0105',
|
||||
];
|
||||
|
||||
Branch::query()->update(['is_dalam_kota' => false]);
|
||||
|
||||
foreach ($codes as $code) {
|
||||
Branch::where('code', 'like', '%' . $code)
|
||||
->update(['is_dalam_kota' => true]);
|
||||
}
|
||||
|
||||
$newBranches = [
|
||||
[
|
||||
'code' => 'ID0012005',
|
||||
'name' => 'KORPORASI',
|
||||
'is_dalam_kota' => true,
|
||||
],
|
||||
[
|
||||
'code' => 'ID0010172',
|
||||
'name' => 'AMBON TUAL MALUKU',
|
||||
'is_dalam_kota' => false,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($newBranches as $branch) {
|
||||
Branch::firstOrCreate(
|
||||
['code' => $branch['code']],
|
||||
[
|
||||
'name' => $branch['name'],
|
||||
'is_dalam_kota' => $branch['is_dalam_kota'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
echo "Seeder update kolom is_dalam_kota + insert data baru selesai!\n";
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
@section('content')
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
@if(isset($branch->id))
|
||||
@if (isset($branch->id))
|
||||
<form action="{{ route('basicdata.branch.update', $branch->id) }}" method="POST">
|
||||
<input type="hidden" name="id" value="{{ $branch->id }}">
|
||||
@method('PUT')
|
||||
@@ -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
|
||||
@@ -53,9 +91,10 @@
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<select class="input @error('parent_id') border-danger bg-danger-light @enderror" name="parent_id">
|
||||
<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' : '' }}>
|
||||
@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' : '' }}>
|
||||
{{ $parentBranch->code }} - {{ $parentBranch->name }}
|
||||
</option>
|
||||
@endif
|
||||
@@ -67,7 +106,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
@if(isset($branch->id))
|
||||
@if (isset($branch->id))
|
||||
@can('basic-data.update')
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Save
|
||||
|
||||
Reference in New Issue
Block a user