namespace App\Exports;
use App\User;
use Maatwebsite\Excel\Concerns\FromCollection;
class UsersExport implements FromCollection
{
public function collection()
{
return User::all();
}
}
Laravel Excel has extensive documentation showing you the basics to simplify the imports and exports in your application. Let Laravel Excel do the heavy lifting for you!
Looking for commercial support, bug-prioritization or need help with a complex import or export? Spartner (formerly known as Maatwebsite) loves to help!
Keep up to date with Laravel Excel by reading the latest release notes.
namespace App\Exports;
use App\User;
use Maatwebsite\Excel\Concerns\FromCollection;
class UsersExport implements FromCollection
{
public function collection()
{
return User::all();
}
}
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],
]);
}
}
namespace App\Nova;
use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;
class User extends Resource
{
public function actions(Request $request)
{
return [
(new DownloadExcel)->withHeadings(),
];
}
}