✨ feat(lpj): Tambah fitur Referensi Link dan perbaikan Bank Data
Menambahkan fitur manajemen referensi link lengkap dengan CRUD, import/export Excel, serta melakukan perbaikan pada modul Bank Data untuk menampilkan semua data. ## Perubahan Detail ### 🔗 Fitur Referensi Link (Baru) **Model & Database:** - Membuat model `ReferensiLink` dengan relasi ke user (created_by, updated_by) - Membuat migration `create_referensi_link_table` dengan struktur lengkap - Menambahkan scopes untuk filtering dan searching **Controller & Request:** - Membuat `ReferensiLinkController` dengan fitur lengkap (CRUD, datatable, export/import) - Membuat `ReferensiLinkRequest` dengan validasi comprehensive - Menambahkan fitur toggle status aktif/inaktif **Export/Import:** - Membuat `ReferensiLinkExport` untuk export ke Excel dengan styling - Membuat `ReferensiLinkImport` untuk import dari Excel dengan validasi - Menambahkan template download untuk import **View & Navigation:** - Menambahkan menu "Referensi Link" di navigasi sistem - Membuat struktur role access untuk administrator dan admin ### 📊 Perbaikan Bank Data **Controller:** - Menambahkan fitur "show_all" untuk menampilkan semua data tanpa pagination - Memperbaiki Log facade import dari `Log` menjadi `Illuminate\Support\Facades\Log` - Menambahkan loading overlay untuk UX yang lebih baik **View:** - Menambahkan checkbox "Tampilkan Semua Data" di filter - Memperbaiki styling dan layout tabel - Menambahkan loading spinner saat filter diterapkan ### 🛠️ Helper & Utilitas **PdfHelper (Baru):** - Membuat helper untuk format teks PDF dengan handling karakter spesial - Menambahkan fungsi untuk konversi simbol matematika ke teks - Memastikan encoding UTF-8 yang proper **ImageController (Baru):** - Membuat controller untuk resize gambar dengan parameter width dan quality - Menggunakan ImageResizeService untuk processing gambar ### 🔧 Perbaikan Lainnya **View Components:** - Memperbaiki syntax HTML dan Blade template - Menambahkan role checking yang lebih proper - Memperbaiki format tampilan nilai menggunakan formatRupiah() ### 📁 File Baru - `Helpers/PdfHelper.php` - Helper untuk format PDF - `Http/Controllers/ImageController.php` - Controller untuk image resize - `Http/Controllers/ReferensiLinkController.php` - Controller referensi link - `Http/Requests/ReferensiLinkRequest.php` - Validasi referensi link - `Exports/ReferensiLinkExport.php` - Export Excel - `Imports/ReferensiLinkImport.php` - Import Excel - `Models/ReferensiLink.php` - Model referensi link - Database migration untuk tabel referensi_link ### 🔄 File Diperbarui - `module.json` - Menambahkan menu navigasi - `BankDataController.php` - Fitur show_all dan perbaikan Log - `resources/views/bank-data/index.blade.php` - UI improvements - Beberapa view components untuk perbaikan syntax dan role checking ## Alasan Perubahan 1. **Fitur Referensi Link**: Menyediakan manajemen link referensi yang terstruktur untuk kebutuhan dokumentasi dan regulasi 2. **Import/Export**: Memudahkan pengelolaan data referensi dalam jumlah besar via Excel 3. **Show All Data**: Memenuhi kebutuhan menampilkan semua data bank data di peta tanpa pagination 4. **PDF Helper**: Menangani masalah karakter spesial dalam generate PDF 5. **Image Controller**: Menyediakan endpoint untuk resize gambar secara dinamis
This commit is contained in:
128
app/Exports/ReferensiLinkExport.php
Normal file
128
app/Exports/ReferensiLinkExport.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Exports;
|
||||
|
||||
use Modules\Lpj\app\Models\ReferensiLink;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class ReferensiLinkExport implements FromQuery, WithHeadings, WithMapping, WithStyles, ShouldAutoSize, WithColumnFormatting
|
||||
{
|
||||
protected $filters;
|
||||
|
||||
public function __construct($filters = [])
|
||||
{
|
||||
$this->filters = $filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query data yang akan diexport
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
$query = ReferensiLink::with(['createdBy', 'updatedBy'])
|
||||
->select('referensi_link.*');
|
||||
|
||||
// Apply filters
|
||||
if (isset($this->filters['kategori']) && !empty($this->filters['kategori'])) {
|
||||
$query->where('kategori', $this->filters['kategori']);
|
||||
}
|
||||
|
||||
if (isset($this->filters['status']) && $this->filters['status'] !== '') {
|
||||
$query->where('is_active', $this->filters['status']);
|
||||
}
|
||||
|
||||
if (isset($this->filters['search']) && !empty($this->filters['search'])) {
|
||||
$query->search($this->filters['search']);
|
||||
}
|
||||
|
||||
return $query->ordered();
|
||||
}
|
||||
|
||||
/**
|
||||
* Header kolom
|
||||
*/
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'No',
|
||||
'Nama',
|
||||
'Link',
|
||||
'Kategori',
|
||||
'Deskripsi',
|
||||
'Status Aktif',
|
||||
'Urutan',
|
||||
'Dibuat Oleh',
|
||||
'Diupdate Oleh',
|
||||
'Tanggal Dibuat',
|
||||
'Tanggal Diupdate',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping data untuk setiap baris
|
||||
*/
|
||||
public function map($referensiLink): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
$rowNumber++;
|
||||
|
||||
return [
|
||||
$rowNumber,
|
||||
$referensiLink->name,
|
||||
$referensiLink->link,
|
||||
$referensiLink->kategori ?? '-',
|
||||
$referensiLink->deskripsi ?? '-',
|
||||
$referensiLink->is_active ? 'Aktif' : 'Tidak Aktif',
|
||||
$referensiLink->urutan,
|
||||
$referensiLink->createdBy ? $referensiLink->createdBy->name : '-',
|
||||
$referensiLink->updatedBy ? $referensiLink->updatedBy->name : '-',
|
||||
$referensiLink->created_at->format('d-m-Y H:i:s'),
|
||||
$referensiLink->updated_at->format('d-m-Y H:i:s'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Styling untuk worksheet
|
||||
*/
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
return [
|
||||
// Header styling
|
||||
1 => [
|
||||
'font' => ['bold' => true, 'size' => 12],
|
||||
'fill' => ['fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, 'startColor' => ['rgb' => 'E2EFDA']],
|
||||
'alignment' => ['horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER],
|
||||
],
|
||||
// Alternating row colors
|
||||
'A2:K1000' => [
|
||||
'fill' => ['fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, 'startColor' => ['rgb' => 'F8F9FA']],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Format kolom
|
||||
*/
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'F' => NumberFormat::FORMAT_DATE_DDMMYYYY, // Tanggal dibuat
|
||||
'G' => NumberFormat::FORMAT_DATE_DDMMYYYY, // Tanggal diupdate
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom title untuk sheet
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return 'Referensi Link';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user