I am working with Laravel Excel 3.1 trying to export file using two parameter
web.php {route file}
Route::post('/Download', 'Controller@Download');
and my controller
public function Download(Request $request)
{
$StartDate = Input::get('StartDate');
$EndDate = Input::get('EndDate');
$exporter = app()->makeWith(UsersExport::class, compact('StartDate','EndDate'));
return $exporter->download('Summary Detail.xlsx');
}
userExporter.php
class UsersExport implements FromQuery, WithHeadings,ShouldAutoSize
{
use Exportable;
protected $StartDate,$EndDate;
public function __construct(String $StartDate,String $EndDate)
{
$this->StartDate = $StartDate;
$this->EndDate = $EndDate;
}
public function query()
{
return databaseReceipt::query()
->whereDate('created_at', '>=', $this->StartDate)
->whereDate('created_at', '<=', $this->EndDate)
->select('id','servicename',"created_at");
}
}
when I use static variable like "00:00 01/04/2017" and "00:00 01/01/2018" for start date & end date it works fine which lead me that passing variables doesn't work