parfum/app/Http/Controllers/ExportController.php

58 lines
1.3 KiB
PHP

<?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'
);
}
}