I have used barryvdh/laravel-dompdf Laravel package for importing Excel file but I am getting the mentioned error in the attached screenshot.
Controller to save an excel file:
if ($request->hasFile('upload_mcq_file') and in_array($request->upload_mcq_file->extension(), array('xlsx', 'xlt', 'xltx', 'xls', 'xls', 'csv'))) {
$image = $request->upload_mcq_file;
$fileName = time() . '.' . $image->getClientOriginalName();
$image->move('admin/mcqs/', $fileName);
$path = 'admin/mcqs/' . $fileName;
}
$data = Excel::import(new MCQPaperImport, $path);
MCQPaperImport Class below:
class MCQPaperImport implements ToModel
{
public function model(array $row)
{
return new MCQPaper([
'product_id' => request('product_id'),
'product_type' => request('product_type'),
'question' => $row[0],
'answer' => $row[1],
'option1' => $row[2],
'option2' => $row[3],
'option3' => $row[4],
'option4' => $row[5],
'mark' => $row[6],
'created_at' => Carbon::now('Asia/Kolkata'),
'updated_at' => Carbon::now('Asia/Kolkata'),
]);
}
}
![Table schema is mentioned in this image][Table schema is mentioned in this image]