-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AfterChunk event for chunked exports (#4037)
* Update AppendQueryToSheet.php Add AfterChunk event for chunked exports * Update AppendQueryToSheet.php * Update AppendQueryToSheet.php * Update AppendQueryToSheet.php * Add test * Fix style * Fix style * Cleanup
- Loading branch information
1 parent
0cbbdb7
commit 104df8a
Showing
3 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Maatwebsite\Excel\Tests\Data\Stubs; | ||
|
||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Maatwebsite\Excel\Concerns\Exportable; | ||
use Maatwebsite\Excel\Concerns\FromQuery; | ||
use Maatwebsite\Excel\Concerns\WithCustomChunkSize; | ||
use Maatwebsite\Excel\Concerns\WithEvents; | ||
use Maatwebsite\Excel\Events\AfterChunk; | ||
use Maatwebsite\Excel\Tests\Data\Stubs\Database\User; | ||
use PHPUnit\Framework\Assert; | ||
|
||
class ExportWithEventsChunks implements WithEvents, FromQuery, ShouldQueue, WithCustomChunkSize | ||
{ | ||
use Exportable; | ||
|
||
public function registerEvents(): array | ||
{ | ||
return [ | ||
AfterChunk::class => function (AfterChunk $event) { | ||
Assert::assertInstanceOf(ExportWithEventsChunks::class, $event->getConcernable()); | ||
}, | ||
]; | ||
} | ||
|
||
public function query(): Builder | ||
{ | ||
return User::query(); | ||
} | ||
|
||
public function chunkSize(): int | ||
{ | ||
return 1; | ||
} | ||
} |