Sign in
Log inSign up

Import Export excel from to database

Mohamed Elghazali's photo
Mohamed Elghazali
·Nov 3, 2021·

1 min read

1) Create brand new laravel app :

composer create-project --prefer-dist laravel/laravel blog

2) Install maatwebsite/excel Package:

composer require maatwebsite/excel

3) open App/config.app and add service provider and aliase.

'providers' => [
     ....
     Maatwebsite\Excel\ExcelServiceProvider::class,
],

'aliases' => [

    ....

    'Excel' => Maatwebsite\Excel\Facades\Excel::class,

],

4) Create Import and Export class :

php artisan make:import UsersImport --model=User

php artisan make:export UsersExport --model=User