Level 53
@mostafalaravel just follow the docs: https://docs.laravel-excel.com/3.1/exports/
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello
I have this simple controller bellow :
<?php
namespace App\Http\Controllers;
use App\User;
use Illuminate\Http\Request;
class excelTest extends Controller
{
public function index(){
$user = User::where('id','>',150)->get();
return $user;
}
}
I would like to download this result as excel file using Maatwebsite.
Thanks
@mostafalaravel what about:
public function competencesExport(Request $request){
return Excel::download(new CompetencesExport($request->all()), 'competences.xlsx');
}
class CompetencesExport implements FromCollection
{
protected $params = [];
public function __construct($params)
{
$this->params = $params;
}
public function collection()
{
return competence::all();
}
}
Please or to participate in this conversation.