My Controller File
public function enquiryExport($id, Request $request)
{
$id[] = $request->explode(",",$id);
return Excel::download(new EnquiryExport($id), 'enquiry.xlsx');
}
and My Export File
protected $id;
function __construct($id) {
$this->id = $id;
}
public function collection()
{
return Enquiry::whereIn('id',explode(",",$this->id))->get();
/* return Enquiry::all(); */
}
Route is like
Route::get('enquiryExport', 'enquiryController@enquiryExport');
Still I am getting this error
"message": "Too few arguments to function App\\Http\\Controllers\\enquiryController::enquiryExport(), 1 passed and exactly 2 expected",
I am checkbox id through AJAX here.
The problems is your
Route
method.Get
method: the query string (name/value pairs) is sent in the URL of a GET requestPost
method: the data sent to the server with POST is stored in the request body of the HTTP requestIf you use
Get
method: try this (I have just read it, not tried)If you use
Post
method: try this (I am used to use this)You can read more here: https://www.w3schools.com/tags/ref_httpmethods.asp