feat: remove all Excel export functionality including controllers, routes, export classes, and UI buttons.

This commit is contained in:
Yoga Pangestu 2026-01-05 22:54:52 +07:00
parent a638760713
commit 610db296f0
10 changed files with 0 additions and 685 deletions

View File

@ -1,132 +0,0 @@
<?php
namespace App\Exports;
use App\Models\Brand;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStyles;
use Maatwebsite\Excel\Concerns\WithTitle;
use Maatwebsite\Excel\Events\AfterSheet;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class BrandExport implements FromCollection, ShouldAutoSize, WithColumnWidths, WithEvents, WithHeadings, WithMapping, WithStyles, WithTitle
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return Brand::all();
}
public function title(): string
{
return 'Data Merek';
}
public function headings(): array
{
return [
'Nama',
'Tanggal Dibuat',
'Tanggal Diperbarui',
];
}
/**
* @param Brand $brand
*/
public function map($brand): array
{
return [
$brand->name,
formatDateLocalized($brand->created_at, 'd/m/Y H:i'),
formatDateLocalized($brand->updated_at, 'd/m/Y H:i'),
];
}
public function columnWidths(): array
{
return [
'A' => 20, // Brand Name
'B' => 18, // Created Date
'C' => 18, // Updated Date
];
}
/**
* @return array
*/
public function styles(Worksheet $sheet)
{
$lastRow = $sheet->getHighestRow();
$lastColumn = $sheet->getHighestColumn();
// Header style
$headerStyle = [
'font' => [
'bold' => true,
'size' => 12,
'color' => ['rgb' => 'FFFFFF'],
],
'fill' => [
'fillType' => Fill::FILL_SOLID,
'startColor' => ['rgb' => '71717A'], // Zinc - elegant
],
'alignment' => [
'horizontal' => Alignment::HORIZONTAL_CENTER,
'vertical' => Alignment::VERTICAL_CENTER,
],
'borders' => [
'allBorders' => [
'borderStyle' => Border::BORDER_THIN,
'color' => ['rgb' => '000000'],
],
],
];
// Data rows style
$dataStyle = [
'borders' => [
'allBorders' => [
'borderStyle' => Border::BORDER_THIN,
'color' => ['rgb' => '000000'],
],
],
'alignment' => [
'vertical' => Alignment::VERTICAL_TOP,
],
];
return [
// Header styling
1 => $headerStyle,
// Data rows styling
'A2:'.$lastColumn.$lastRow => $dataStyle,
];
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
// Auto-size columns with max width
foreach (range('A', 'C') as $column) {
$event->sheet->getColumnDimension($column)->setAutoSize(true);
}
// Set row height for header
$event->sheet->getRowDimension(1)->setRowHeight(25);
},
];
}
}

View File

@ -1,138 +0,0 @@
<?php
namespace App\Exports;
use App\Models\Formula;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStyles;
use Maatwebsite\Excel\Concerns\WithTitle;
use Maatwebsite\Excel\Events\AfterSheet;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class FormulaExport implements FromCollection, ShouldAutoSize, WithColumnWidths, WithEvents, WithHeadings, WithMapping, WithStyles, WithTitle
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return Formula::all();
}
public function title(): string
{
return 'Data Rumus';
}
public function headings(): array
{
return [
'Kualitas',
'Ukuran (ML)',
'Volume (ML)',
'Tanggal Dibuat',
'Tanggal Diperbarui',
];
}
/**
* @param Formula $formula
*/
public function map($formula): array
{
return [
$formula->quality,
$formula->size,
$formula->volume,
formatDateLocalized($formula->created_at, 'd/m/Y H:i'),
formatDateLocalized($formula->updated_at, 'd/m/Y H:i'),
];
}
public function columnWidths(): array
{
return [
'A' => 18, // Quality
'B' => 15, // Size (ML)
'C' => 15, // Volume (ML)
'D' => 21, // Created Date
'E' => 21, // Updated Date
];
}
/**
* @return array
*/
public function styles(Worksheet $sheet)
{
$lastRow = $sheet->getHighestRow();
$lastColumn = $sheet->getHighestColumn();
// Header style
$headerStyle = [
'font' => [
'bold' => true,
'size' => 12,
'color' => ['rgb' => 'FFFFFF'],
],
'fill' => [
'fillType' => Fill::FILL_SOLID,
'startColor' => ['rgb' => '475569'], // Slate - elegant
],
'alignment' => [
'horizontal' => Alignment::HORIZONTAL_CENTER,
'vertical' => Alignment::VERTICAL_CENTER,
],
'borders' => [
'allBorders' => [
'borderStyle' => Border::BORDER_THIN,
'color' => ['rgb' => '000000'],
],
],
];
// Data rows style
$dataStyle = [
'borders' => [
'allBorders' => [
'borderStyle' => Border::BORDER_THIN,
'color' => ['rgb' => '000000'],
],
],
'alignment' => [
'vertical' => Alignment::VERTICAL_TOP,
],
];
return [
// Header styling
1 => $headerStyle,
// Data rows styling
'A2:'.$lastColumn.$lastRow => $dataStyle,
];
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
// Auto-size columns with max width
foreach (range('A', 'E') as $column) {
$event->sheet->getColumnDimension($column)->setAutoSize(true);
}
// Set row height for header
$event->sheet->getRowDimension(1)->setRowHeight(25);
},
];
}
}

View File

@ -1,168 +0,0 @@
<?php
namespace App\Exports;
use App\Models\Perfume;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStyles;
use Maatwebsite\Excel\Concerns\WithTitle;
use Maatwebsite\Excel\Events\AfterSheet;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class PerfumeExport implements FromCollection, ShouldAutoSize, WithColumnWidths, WithEvents, WithHeadings, WithMapping, WithStyles, WithTitle
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return Perfume::with('brand')->get();
}
public function title(): string
{
return 'Data Parfum';
}
public function headings(): array
{
return [
'Aroma',
'SKU',
'Merek',
'Konsentrasi',
'Harga Jual',
'Base Notes',
'Middle Notes',
'Top Notes',
'Deskripsi',
'Tanggal Dibuat',
'Tanggal Diperbarui',
];
}
/**
* @param Perfume $perfume
*/
public function map($perfume): array
{
return [
$perfume->name,
$perfume->sku,
$perfume->brand?->name,
$perfume->concentration->label(),
$perfume->sale_price,
$perfume->base_notes,
$perfume->middle_notes,
$perfume->top_notes,
strip_tags($perfume->description),
formatDateLocalized($perfume->created_at, 'd/m/Y H:i'),
formatDateLocalized($perfume->updated_at, 'd/m/Y H:i'),
];
}
public function columnWidths(): array
{
return [
'A' => 28, // Perfume Name
'B' => 18, // SKU
'C' => 23, // Brand
'D' => 23, // Concentration
'E' => 18, // Sale Price
'F' => 23, // Base Notes
'G' => 23, // Middle Notes
'H' => 23, // Top Notes
'I' => 35, // Description
'J' => 21, // Created Date
'K' => 21, // Updated Date
];
}
/**
* @return array
*/
public function styles(Worksheet $sheet)
{
$lastRow = $sheet->getHighestRow();
$lastColumn = $sheet->getHighestColumn();
// Header style
$headerStyle = [
'font' => [
'bold' => true,
'size' => 12,
'color' => ['rgb' => 'FFFFFF'],
],
'fill' => [
'fillType' => Fill::FILL_SOLID,
'startColor' => ['rgb' => '1E40AF'], // Navy Blue - elegant
],
'alignment' => [
'horizontal' => Alignment::HORIZONTAL_CENTER,
'vertical' => Alignment::VERTICAL_CENTER,
],
'borders' => [
'allBorders' => [
'borderStyle' => Border::BORDER_THIN,
'color' => ['rgb' => '000000'],
],
],
];
// Data rows style
$dataStyle = [
'borders' => [
'allBorders' => [
'borderStyle' => Border::BORDER_THIN,
'color' => ['rgb' => '000000'],
],
],
'alignment' => [
'vertical' => Alignment::VERTICAL_TOP,
'horizontal' => Alignment::HORIZONTAL_LEFT,
'indent' => 1, // Add padding
],
];
// Currency columns style (format currency)
$currencyStyle = [
'numberFormat' => [
'formatCode' => '"Rp" #,##0',
],
];
return [
// Header styling
1 => $headerStyle,
// Data rows styling
'A2:'.$lastColumn.$lastRow => $dataStyle,
// Currency columns styling
'E2:E'.$lastRow => $currencyStyle,
];
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
// Auto-size columns with max width
foreach (range('A', 'K') as $column) {
$event->sheet->getColumnDimension($column)->setAutoSize(true);
}
// Set row height for header
$event->sheet->getRowDimension(1)->setRowHeight(25);
},
];
}
}

View File

@ -1,153 +0,0 @@
<?php
namespace App\Exports;
use App\Models\Product;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStyles;
use Maatwebsite\Excel\Concerns\WithTitle;
use Maatwebsite\Excel\Events\AfterSheet;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class ProductExport implements FromCollection, ShouldAutoSize, WithColumnWidths, WithEvents, WithHeadings, WithMapping, WithStyles, WithTitle
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return Product::all();
}
public function title(): string
{
return 'Data Produk Botol';
}
public function headings(): array
{
return [
'Nama',
'SKU',
'Harga Jual',
'Deskripsi',
'Tanggal Dibuat',
'Tanggal Diperbarui',
];
}
/**
* @param Product $product
*/
public function map($product): array
{
return [
$product->name,
$product->sku,
$product->sale_price,
strip_tags($product->description) ?: '-',
formatDateLocalized($product->created_at, 'd/m/Y H:i'),
formatDateLocalized($product->updated_at, 'd/m/Y H:i'),
];
}
public function columnWidths(): array
{
return [
'A' => 28, // Product Name
'B' => 18, // SKU
'C' => 18, // Sale Price
'D' => 35, // Description
'E' => 21, // Created Date
'F' => 21, // Updated Date
];
}
/**
* @return array
*/
public function styles(Worksheet $sheet)
{
$lastRow = $sheet->getHighestRow();
$lastColumn = $sheet->getHighestColumn();
// Header style
$headerStyle = [
'font' => [
'bold' => true,
'size' => 12,
'color' => ['rgb' => 'FFFFFF'],
],
'fill' => [
'fillType' => Fill::FILL_SOLID,
'startColor' => ['rgb' => '0F766E'], // Teal - elegant
],
'alignment' => [
'horizontal' => Alignment::HORIZONTAL_CENTER,
'vertical' => Alignment::VERTICAL_CENTER,
],
'borders' => [
'allBorders' => [
'borderStyle' => Border::BORDER_THIN,
'color' => ['rgb' => '000000'],
],
],
];
// Data rows style
$dataStyle = [
'borders' => [
'allBorders' => [
'borderStyle' => Border::BORDER_THIN,
'color' => ['rgb' => '000000'],
],
],
'alignment' => [
'vertical' => Alignment::VERTICAL_TOP,
'horizontal' => Alignment::HORIZONTAL_LEFT,
'indent' => 1, // Add padding
],
];
// Currency columns style (format currency)
$currencyStyle = [
'numberFormat' => [
'formatCode' => '"Rp" #,##0',
],
];
return [
// Header styling
1 => $headerStyle,
// Data rows styling
'A2:'.$lastColumn.$lastRow => $dataStyle,
// Currency columns styling
'C2:C'.$lastRow => $currencyStyle,
];
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
// Auto-size columns with max width
foreach (range('A', 'F') as $column) {
$event->sheet->getColumnDimension($column)->setAutoSize(true);
}
// Set row height for header
$event->sheet->getRowDimension(1)->setRowHeight(25);
},
];
}
}

View File

@ -1,57 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Exports\BrandExport;
use App\Exports\FormulaExport;
use App\Exports\PerfumeExport;
use App\Exports\ProductExport;
use Maatwebsite\Excel\Facades\Excel;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class ExportController extends Controller
{
/**
* Export perfumes to Excel
*/
public function perfumes(): BinaryFileResponse
{
return Excel::download(
new PerfumeExport,
'data_parfum_'.now()->format('Y-m-d_H-i-s').'.xlsx'
);
}
/**
* Export products to Excel
*/
public function products(): BinaryFileResponse
{
return Excel::download(
new ProductExport,
'data_produk_botol_'.now()->format('Y-m-d_H-i-s').'.xlsx'
);
}
/**
* Export formulas to Excel
*/
public function formulas(): BinaryFileResponse
{
return Excel::download(
new FormulaExport,
'data_rumus_'.now()->format('Y-m-d_H-i-s').'.xlsx'
);
}
/**
* Export brands to Excel
*/
public function brands(): BinaryFileResponse
{
return Excel::download(
new BrandExport,
'data_merek_'.now()->format('Y-m-d_H-i-s').'.xlsx'
);
}
}

View File

@ -4,13 +4,6 @@
<flux:heading size="xl">{{ $pageTitle }}</flux:heading> <flux:heading size="xl">{{ $pageTitle }}</flux:heading>
</div> </div>
<div class="flex gap-2"> <div class="flex gap-2">
@can('view brand')
<a href="{{ route('studio.export.brand') }}" class="inline-flex">
<flux:button variant="primary" color="zinc" class="text-sm">
Ekspor Ecxel
</flux:button>
</a>
@endcan
@can('create brand') @can('create brand')
<flux:modal.trigger name="form-modal"> <flux:modal.trigger name="form-modal">
<flux:button variant="primary" class="text-sm" <flux:button variant="primary" class="text-sm"

View File

@ -4,13 +4,6 @@
<flux:heading size="xl">{{ $pageTitle }}</flux:heading> <flux:heading size="xl">{{ $pageTitle }}</flux:heading>
</div> </div>
<div class="flex gap-2"> <div class="flex gap-2">
@can('view perfume')
<a href="{{ route('studio.export.perfume') }}" class="inline-flex">
<flux:button variant="primary" color="zinc" class="text-sm">
Ekspor Ecxel
</flux:button>
</a>
@endcan
@can('create perfume') @can('create perfume')
<flux:button href="{{ route('studio.catalog.perfume.create') }}" variant="primary" wire:navigate <flux:button href="{{ route('studio.catalog.perfume.create') }}" variant="primary" wire:navigate
class="text-sm"> class="text-sm">

View File

@ -4,13 +4,6 @@
<flux:heading size="xl">{{ $pageTitle }}</flux:heading> <flux:heading size="xl">{{ $pageTitle }}</flux:heading>
</div> </div>
<div class="flex gap-2"> <div class="flex gap-2">
@can('view product')
<a href="{{ route('studio.export.product') }}" class="inline-flex">
<flux:button variant="primary" color="zinc" class="text-sm">
Ekspor Ecxel
</flux:button>
</a>
@endcan
@can('create product') @can('create product')
<flux:button href="{{ route('studio.catalog.product.create') }}" variant="primary" wire:navigate <flux:button href="{{ route('studio.catalog.product.create') }}" variant="primary" wire:navigate
class="text-sm"> class="text-sm">

View File

@ -4,13 +4,6 @@
<flux:heading size="xl">{{ $pageTitle }}</flux:heading> <flux:heading size="xl">{{ $pageTitle }}</flux:heading>
</div> </div>
<div class="flex gap-2"> <div class="flex gap-2">
@can('view formula')
<a href="{{ route('studio.export.formula') }}" class="inline-flex">
<flux:button variant="primary" color="zinc" class="text-sm">
Ekspor Ecxel
</flux:button>
</a>
@endcan
@can('create formula') @can('create formula')
<flux:modal.trigger name="form-modal"> <flux:modal.trigger name="form-modal">
<flux:button variant="primary" class="text-sm" <flux:button variant="primary" class="text-sm"

View File

@ -1,6 +1,5 @@
<?php <?php
use App\Http\Controllers\ExportController;
use App\Livewire\Studio\Catalog\Bottle\Audit as BottleAudit; use App\Livewire\Studio\Catalog\Bottle\Audit as BottleAudit;
use App\Livewire\Studio\Catalog\Bottle\Create as BottleCreate; use App\Livewire\Studio\Catalog\Bottle\Create as BottleCreate;
use App\Livewire\Studio\Catalog\Bottle\Edit as BottleEdit; use App\Livewire\Studio\Catalog\Bottle\Edit as BottleEdit;
@ -207,12 +206,4 @@
Route::get('/', ChooseUsComponent::class)->name('index')->middleware('can:view choose us'); Route::get('/', ChooseUsComponent::class)->name('index')->middleware('can:view choose us');
}); });
}); });
// Export Routes
Route::prefix('export')->name('studio.export.')->group(function () {
Route::get('/perfumes', [ExportController::class, 'perfumes'])->name('perfume')->middleware('can:view perfume');
Route::get('/products', [ExportController::class, 'products'])->name('product')->middleware('can:view product');
Route::get('/formulas', [ExportController::class, 'formulas'])->name('formula')->middleware('can:view formula');
Route::get('/brands', [ExportController::class, 'brands'])->name('brand')->middleware('can:view brand');
});
}); });