Import data as CSV file

If you want to import data, just you need to call the method. Assume we are going to import user and we have a route to import user and the method name is import


use App\Models\User;
use Illuminate\Http\Request;
use App\Helpers\ChunkImporter;
use App\Http\Controllers\Controller;

public function import(Request $request)
    (new ChunkImporter())->importByChunkingData(
        User::class, // model we need to import
        'email', //unique column we need to update if duplicate column found
        $request->csv, // file to be uploaded
        100 // chunk number 

    return $this->success('user', 'User imported successfully!');