在 Laravel 中导入时如何保存 csv

How to save the csv when i import it in Laravel

我是 Laravel 的新人,我有一个导入列表页面(这个页面工作得很好),这个导入一些列表放在数据库中。但是我也想保存这个列表。

这是我的代码 (CsvImport.php):

<?php

namespace App\Imports;

use App\Product;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Illuminate\Support\Facades\Auth;

class CsvImport implements ToModel, WithHeadingRow
{
    public function model(array $row)
    {
        return Product::query()->forceCreate([
            'name'        => $row["name"],
            'description' => $row["description"],
            'category'    => $row["category"],
            'price'       => $row["price"],
            'image'       => 'no-image.jpg',
            'user_id'     =>  Auth::user()->id,
        ]);
    }
}

一些想法? :)

没找到,不过我觉得还是不要存为好。