tayyabshahzad1's avatar

Update record using Maatwebsite

Hi, I am Using Maatwebsite Packege to upload excel file into my app. What I have done so far, I just make a form and import my CSV, all things are working fine. But I want it when the user uploads the file it should update all records based on the id mentioned in my CSV file. I don't have any idea how I can do this

my Upload file code is below

   Route::post('import', [App\Http\Controllers\dataController::class, 'import'])->name('import');
   public function import()
    {
         Excel::import(new SuccessImport,request()->file('file'));
         return back();
    }

my Import Class

	return new Successfull([
            'id'    => $row[0],
            'first_name'    => $row[1],
            'last_name'    => $row[2],
            'email' => $row[3],
            'reservation_id' => $row[4],
            'entry_id' => $row[5],
            'products' => $row[6],
            'shopify_order_id' => $row[7],
        ]);
0 likes
5 replies
indexcodes's avatar

I'm using an update template already on created tables. I created an UpdateImport.php file and added the code below

But I get an error: Class App\Imports\CatalogUpdateImport contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Maatwebsite\Excel\Concerns\WithUpserts::uniqueBy) I can't figure out what it is, it accuses the CatalogUpdateImport class

namespace App\Imports;

use App\Models\CatalogStore; use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\WithUpserts; use Maatwebsite\Excel\Concerns\WithUpsertColumns;

class CatalogUpdateImport implements ToModel, WithUpserts, WithUpsertColumns {

Please or to participate in this conversation.