I'm using laravel excel package to upload and use excel files with laravel. When I upload a file with unsupported format (E.g.:- .doc file) I get this exception.
Maatwebsite \ Excel \ Exceptions \ NoTypeDetectedException No message
But instead I need to use a flash message like this.
flash("Sorry you are using a wrong format to upload files.")->error();
return Redirect::back();
This is my code.
$file = $request->file('file');
Excel::import(new MyImport, $file);
This is my import file
<?php
namespace App\Imports;
use Maatwebsite\Excel\Concerns\ToModel;
class MyImport implements ToModel
{
public function model(array $row)
{
...
}
}