lundi 22 juin 2020

Laravel import Seller_id from Excel File

I'm building multi Shops Platform, So i'm able to manage shop's products from admin panel

i'm using this package to import products from excel file to specific Shop, and i've Shop_id in Products Table

Now, I'm able to import excel file to database successfully. But, The problem is to assign Shop_id in for each product

Any Ideas to do that ?

PruductImport.php

public function model(array $row)
    {
        return new Product([
            'name'         => $row['Name'],
            'price'        => $row['Price'],
        ]);
    } 

Controller

public function import(Request $request)
    {
        Excel::import(new PruductImport,request()->file('file'));

        return back()->with('success','Done!');
    }


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire