feat(branch): tambah kolom baru dan dukungan pencarian terkait data cabang
- Menambahkan kolom baru pada tabel `branches` melalui migrasi: - `address` - `mnemonic` - `customer_company` - `customer_mnemonic` - `company_group` - `curr_no` - `co_code` - `l_vendor_atm` - `l_vendor_cpc` - Memperbarui model `Branch` agar mendukung kolom baru di properti `fillable`. - Menambahkan dukungan pencarian berdasarkan kolom `address` pada: - `BranchExport.php` (untuk ekspor data) - `BranchController.php` (untuk API pencarian data cabang) - Memperbarui tampilan daftar cabang (`branch/index.blade.php`) untuk menampilkan kolom `address`. - Memperbarui format data ekspor cabang dengan menambahkan kolom `address`. - Memperbaiki pengaturan format kolom tanggal pada data ekspor. Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
$query->where(function ($q) use ($search) {
|
$query->where(function ($q) use ($search) {
|
||||||
$q->whereRaw('LOWER(code) LIKE ?', ['%' . $search . '%'])
|
$q->whereRaw('LOWER(code) LIKE ?', ['%' . $search . '%'])
|
||||||
->orWhereRaw('LOWER(name) LIKE ?', ['%' . $search . '%'])
|
->orWhereRaw('LOWER(name) LIKE ?', ['%' . $search . '%'])
|
||||||
|
->orWhereRaw('LOWER(address) LIKE ?', ['%' . $search . '%'])
|
||||||
->orWhereHas('parent', function ($q) use ($search) {
|
->orWhereHas('parent', function ($q) use ($search) {
|
||||||
$q->whereRaw('LOWER(name) LIKE ?', ['%' . strtolower($search) . '%']);
|
$q->whereRaw('LOWER(name) LIKE ?', ['%' . strtolower($search) . '%']);
|
||||||
});
|
});
|
||||||
@@ -51,6 +52,7 @@
|
|||||||
$row->code,
|
$row->code,
|
||||||
$row->name,
|
$row->name,
|
||||||
$row->parent ? $row->parent->name : '',
|
$row->parent ? $row->parent->name : '',
|
||||||
|
$row->address,
|
||||||
$row->created_at
|
$row->created_at
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -63,6 +65,7 @@
|
|||||||
'Code',
|
'Code',
|
||||||
'Name',
|
'Name',
|
||||||
'Parent Branch',
|
'Parent Branch',
|
||||||
|
'Address',
|
||||||
'Created At'
|
'Created At'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -72,7 +75,7 @@
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'A' => NumberFormat::FORMAT_NUMBER,
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
'D' => NumberFormat::FORMAT_DATE_DATETIME
|
'E' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,6 +189,7 @@
|
|||||||
$query->where(function ($q) use ($search_) {
|
$query->where(function ($q) use ($search_) {
|
||||||
$q->whereRaw('LOWER(code) LIKE ?', ['%' . strtolower($search_) . '%']);
|
$q->whereRaw('LOWER(code) LIKE ?', ['%' . strtolower($search_) . '%']);
|
||||||
$q->orWhereRaw('LOWER(name) LIKE ?', ['%' . strtolower($search_) . '%']);
|
$q->orWhereRaw('LOWER(name) LIKE ?', ['%' . strtolower($search_) . '%']);
|
||||||
|
$q->orWhereRaw('LOWER(address) LIKE ?', ['%' . strtolower($search_) . '%']);
|
||||||
$q->orWhereHas('parent', function ($q) use ($search_) {
|
$q->orWhereHas('parent', function ($q) use ($search_) {
|
||||||
$q->whereRaw('LOWER(name) LIKE ?', ['%' . strtolower($search_) . '%']);
|
$q->whereRaw('LOWER(name) LIKE ?', ['%' . strtolower($search_) . '%']);
|
||||||
});
|
});
|
||||||
@@ -233,6 +234,7 @@
|
|||||||
'code' => $item->code,
|
'code' => $item->code,
|
||||||
'name' => $item->name,
|
'name' => $item->name,
|
||||||
'parent_id' => $item->parent?->name ?? null,
|
'parent_id' => $item->parent?->name ?? null,
|
||||||
|
'address' => str_replace(']', "", $item->address),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,24 @@
|
|||||||
class Branch extends Base
|
class Branch extends Base
|
||||||
{
|
{
|
||||||
protected $table = 'branches';
|
protected $table = 'branches';
|
||||||
protected $fillable = ['code', 'name', 'status', 'authorized_at', 'authorized_status', 'authorized_by', 'parent_id'];
|
protected $fillable = [
|
||||||
|
'code',
|
||||||
|
'name',
|
||||||
|
'address',
|
||||||
|
'mnemonic',
|
||||||
|
'customer_company',
|
||||||
|
'customer_mnemonic',
|
||||||
|
'company_group',
|
||||||
|
'curr_no',
|
||||||
|
'co_code',
|
||||||
|
'l_vendor_atm',
|
||||||
|
'l_vendor_cpc',
|
||||||
|
'status',
|
||||||
|
'authorized_at',
|
||||||
|
'authorized_status',
|
||||||
|
'authorized_by',
|
||||||
|
'parent_id'
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the parent branch of this branch
|
* Get the parent branch of this branch
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?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->string('address')->nullable()->after('name');
|
||||||
|
$table->string('mnemonic')->nullable()->after('address');
|
||||||
|
$table->string('customer_company')->nullable()->after('mnemonic');
|
||||||
|
$table->string('customer_mnemonic')->nullable()->after('customer_company');
|
||||||
|
$table->string('company_group')->nullable()->after('customer_mnemonic');
|
||||||
|
$table->string('curr_no')->nullable()->after('company_group');
|
||||||
|
$table->string('co_code')->nullable()->after('curr_no');
|
||||||
|
$table->boolean('l_vendor_atm')->default(false)->after('co_code');
|
||||||
|
$table->boolean('l_vendor_cpc')->default(false)->after('l_vendor_atm');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('branches', function (Blueprint $table) {
|
||||||
|
$table->dropColumn([
|
||||||
|
'address',
|
||||||
|
'mnemonic',
|
||||||
|
'customer_company',
|
||||||
|
'customer_mnemonic',
|
||||||
|
'company_group',
|
||||||
|
'curr_no',
|
||||||
|
'co_code',
|
||||||
|
'l_vendor_atm',
|
||||||
|
'l_vendor_cpc'
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -57,6 +57,10 @@
|
|||||||
<span class="sort"> <span class="sort-label"> Cabang Induk</span>
|
<span class="sort"> <span class="sort-label"> Cabang Induk</span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
|
<th class="min-w-[250px]" data-datatable-column="address">
|
||||||
|
<span class="sort"> <span class="sort-label"> Address</span>
|
||||||
|
<span class="sort-icon"> </span> </span>
|
||||||
|
</th>
|
||||||
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
|
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -183,6 +187,9 @@
|
|||||||
parent_id: {
|
parent_id: {
|
||||||
title: 'Cabang Induk',
|
title: 'Cabang Induk',
|
||||||
},
|
},
|
||||||
|
address: {
|
||||||
|
title: 'Address',
|
||||||
|
},
|
||||||
actions: {
|
actions: {
|
||||||
title: 'Status',
|
title: 'Status',
|
||||||
render: (item, data) => {
|
render: (item, data) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user