Home > OS >  Import excel file with relationship in Laravel
Import excel file with relationship in Laravel

Time:08-30

I've encountered a problem with importing an excel file in Laravel. I have a single excel file with multiple columns and an ER Diagram as shown below. I want to import that excel file to my Laravel project and my MySQL database will receive the exact information and relationship in my ERD.
( excel ERD)
I've searched and found Laravel Excel (maatwebsite/excel) but I quite don't know how to implement it in my problem. Is that package possible in my case? I'm looking forward to your reply.
I'm using Laravel 8 and maatwebsite/excel 3.1.
This is the first time I posted here so I'm not allow to import images. Sorry for that. Thanks and have a good day!

CodePudding user response:

Yes you can definitively use laravel Excel package. You can have a look at the documentation here: https://docs.laravel-excel.com/3.1/imports/basics.html If I understand correctly you want your data to be imported into several models and managing the relationships so you'll have to import your data and then handle the imported data in your scripts by creating every model and adding the relationships to each.

  • Related