laravel maatwebsite excel code example

Example 1: Maatwebsite\Excel\ install laravel

php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config

Example 2: laravel excel

namespace App\Imports;

use App\User;
use Maatwebsite\Excel\Concerns\ToModel;

class UsersImport implements ToModel
{

}

Example 3: laravel excel

namespace App\Imports;

use App\User;
use Maatwebsite\Excel\Concerns\ToModel;

class UsersImport implements ToModel
{
    public function model(array $row)
    {
        return new User([
           'email'    => $row[1],
        ])
    }
}

Tags:

Sql Example