在laravel导入中验证excel文件时不显示mesage

在laravel导入中验证excel文件时不显示mesage,laravel,laravel-excel,Laravel,Laravel Excel,我在Laravel中使用excel 3.1导入excel文件。我已经包含了名称字段的验证。因此,每当name字段复制时,它都不会将该行数据导入数据库。到目前为止,一切正常。但问题是我想在控制器中显示成功消息。但该消息未显示,也未显示任何其他错误消息。 这是我的导入功能 namespace App\Imports; use App\Products; use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\Wi

我在Laravel中使用excel 3.1导入excel文件。我已经包含了名称字段的验证。因此,每当name字段复制时,它都不会将该行数据导入数据库。到目前为止,一切正常。但问题是我想在控制器中显示成功消息。但该消息未显示,也未显示任何其他错误消息。 这是我的导入功能

namespace App\Imports;

use App\Products;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithStartRow;
use Maatwebsite\Excel\Concerns\SkipsOnError;
use Maatwebsite\Excel\Concerns\SkipsErrors;
use Maatwebsite\Excel\Concerns\Importable;
use App\Categories;
use App\Brand;
use App\Unit;
use Maatwebsite\Excel\Concerns\WithValidation;
// use Illuminate\Validation\Rule;
// use Throwable;
class ExcelImport implements ToModel, WithStartRow, WithValidation, SkipsOnError
{
    use Importable, SkipsErrors;
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */
    public function model(array $row)
    {
        $name = $row[0];
        $des = $row[1];
        
      
            $product = new Products([
                'name' => $row[0],
                'description' => $row[1],
            ]);
            return $product;
       }

    
    public function startRow(): int
    {
        return 2;
    }
    public function rules(): array{
        return[
            '0' => 'unique:products,name',
        
        ];
    }

    
}
这是我的控制器

public function uploadfile(Request $request)
    {
        $this->validate($request, [
            'file' => 'required',           
        ]);

        if($request->hasfile('file'))
        {
            
            foreach($request->file('file') as $file)
            {
               
                $import = new ExcelImport;
                $import = $import->import($file);
                
            }
         //if the import is successful then I want to show some messages here
        }
            
        else{
            return back()->with('error','File contains invalid data. Please upload a valid file.');
        }
    }

欢迎来到堆栈溢出!提问前请先阅读和“”。更具体地说,帮助其他人重现问题我没有得到任何关于controller中函数的信息。你能更具体一点吗?@ClémentBaconnier好的。我已经更新了这个问题。它是否达到
return redirect()->back()->with('success','…')?@ClémentBaconnier编号