导入包含上传 laravel-Excel 的用户详细信息的 csv 数据

import csv data with user details who uploading laravel-Excel

这是我的导入函数

public function csv_import(Request $request){
    if (! Gate::allows('add')) {
        return abort(401);
    }

    // Increase Execution time
    ini_set('max_execution_time', 1200);

    request()->validate([
        'file'  => 'required|max:100240',
    ]);

    Excel::import(new CsvImport, request()->file('file'));

    return redirect()->route('admin.forms.create')->with(Session::flash('success', 'Your Data Has Been Successfully Uploaded'));
}
  I am not sure with your question. But, If you want to know all activities who created or updated your data into database you can use it with bootable that allow you track action.
public static function boot()
{

    parent::boot();

    // create a event to happen on updating
    static::updating(function ($table) {
        $table->updated_by = Auth::user()->id;
    });

    // create a event to happen on saving
    static::saving(function ($table) {
        $table->created_by = Auth::user()->id;
    });
}

你可以试试这个:

 $result = Excel::import(new CsvImport, request()->file('file'));
 check $result is success or fail
 $result is true then => update "user_id" field
 E.g  ImportModel->update(['user_id' => Auth::user()->id]);