-
-
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.
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Maatwebsite\Excel\Tests\Data\Stubs; | ||
|
||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder; | ||
use Illuminate\Database\Eloquent\Relations\Relation; | ||
use Illuminate\Database\Query\Builder; | ||
use Maatwebsite\Excel\Concerns\Exportable; | ||
use Maatwebsite\Excel\Concerns\FromQuery; | ||
use Maatwebsite\Excel\Concerns\WithCustomChunkSize; | ||
use Maatwebsite\Excel\Tests\Data\Stubs\Database\User; | ||
|
||
class FromUsersQueryWithJoinExport implements FromQuery, WithCustomChunkSize | ||
{ | ||
use Exportable; | ||
|
||
public $query; | ||
|
||
public function __construct() | ||
{ | ||
$this->query = User::query(); | ||
} | ||
|
||
/** | ||
* @return Builder|EloquentBuilder|Relation | ||
*/ | ||
public function query() | ||
{ | ||
return $this->query | ||
->join( | ||
'group_user', | ||
'group_user.user_id', | ||
'=', | ||
'users.id' | ||
) | ||
->select('users.*', 'group_user.group_id as gid'); | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function chunkSize(): int | ||
{ | ||
return 1000; | ||
} | ||
} |