-
I am using However, when users have Internet Download Manager (IDM) installed, it takes over the download process. I want to ensure that the file is directly downloaded through the browser and not via IDM. My current codepublic function export(Request $request)
{
if (!$request->hasValidSignature()) {
abort(403, 'Link tidak valid atau sudah kadaluarsa.');
}
$token = $request->query('token');
Cache::forget('export-token:' . $token);
$date = $request->input('date');
$formattedDate = Carbon::parse($date)->format('d-m-Y');
return Excel::download(new SiswaExport($date), "siswa-{$formattedDate}.xlsx");
} And export code<?php
namespace App\Exports;
use App\Models\Siswa;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
class SiswaExport implements FromCollection, WithHeadings, WithMapping, ShouldAutoSize
{
public function collection()
{
return Siswa::with(['user', 'kelas'])->get();
}
public function headings(): array
{
return ['No', 'Nama', 'Username', 'Kelas', 'Jenis Kelamin', 'Jurusan',];
}
public function map($siswa): array
{
static $no = 1;
return [
$no++,
$siswa->user->nama ?? 'N/A',
$siswa->user->username ?? 'N/A',
$siswa->kelas->kelas ?? '-',
ucfirst($siswa->jenis_kelamin ?? '-'),
$siswa->jurusan ?? '-',
];
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
ca-kraa
May 21, 2025
Replies: 1 comment
-
SOLVED!!! Turns out, the automatic download only happens locally through a third party. But in production, it will be automatically downloaded via the default browser. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ca-kraa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SOLVED!!!
Turns out, the automatic download only happens locally through a third party. But in production, it will be automatically downloaded via the default browser.