123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace Maatwebsite\Excel\Tests\Data\Stubs;
- use Illuminate\Database\Eloquent\Collection;
- use Maatwebsite\Excel\Concerns\Exportable;
- use Maatwebsite\Excel\Concerns\FromCollection;
- use Maatwebsite\Excel\Concerns\WithMapping;
- use Maatwebsite\Excel\Tests\Data\Stubs\Database\User;
- class EloquentCollectionWithMappingExport implements FromCollection, WithMapping
- {
- use Exportable;
- /**
- * @return Collection
- */
- public function collection()
- {
- return collect([
- new User([
- 'firstname' => 'Patrick',
- 'lastname' => 'Brouwers',
- ]),
- ]);
- }
- /**
- * @param User $user
- * @return array
- */
- public function map($user): array
- {
- return [
- $user->firstname,
- $user->lastname,
- ];
- }
- }
|