How to get input request in laravel maatwebsite export and import?

Laravel

Nicesnippets

2450

29-04-2020


Hello Guys,

Using request() helper you can get all input fields. How to pass parameter to export file of Laravel Excel for DB query. How can I pass parameter in the laravel excel?. Laravel excel passing varable to exporte. In laravel excel import export how to get form value. if you have to use request variable in maatwebsite import export.

app/Exports/DriverExport.php


namespace App\Exports;

use App\Driver;

use Maatwebsite\Excel\Concerns\FromView;

use Illuminate\Contracts\View\View;

use Illuminate\Http\Request;

use Config;

class DriverExport implements FromView

{

/**

* @return \Illuminate\Support\Collection

*/

public function view(): View

{

$input = request()->all();

$driver = Driver::with('user')->where('type',$input['type'])->latest()->get();

return view('drivers.exportDriver', [

'driver' => $driver

]);

}

}

I hope it can help you...