Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.0 kB
2
Indexable
Never
public function uploadExcel(Request $request)
    {

        // Excel::import(new MypesImport, $request->file('file')->store('temp'));
        // Excel::queueImport(new MypesImport, $request->file('file')->store('temp'));

        try {
            // Excel::import(
            //     new QueuedImport,
            //     $request->file('file')->store('temp')
            // );
            (new QueuedImport)->import($request->file('file')->store('temp'), null, \Maatwebsite\Excel\Excel::XLSX);

        } catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
            $failures = $e->failures();

            foreach ($failures as $failure) {
                $failure->row(); // row that went wrong
                $failure->attribute(); // either heading key (if using heading row concern) or column index
                $failure->errors(); // Actual error messages from Laravel validator
                $failure->values(); // The values of the row that has failed.
            }
       }
    }
Leave a Comment