-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] Added class and method to create cross joined sequences for fac…
…tories (#40542) * Added class to create matrix sequences for factories * Fix for php7.3 support * Rename MatrixSequence to CrossJoinSequence. Add crossJoinSequence method to Factory. * Fix import order lint failure.
- Loading branch information
1 parent
ffba472
commit 22e32b9
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/Illuminate/Database/Eloquent/Factories/CrossJoinSequence.php
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,26 @@ | ||
<?php | ||
|
||
namespace Illuminate\Database\Eloquent\Factories; | ||
|
||
use Illuminate\Support\Arr; | ||
|
||
class CrossJoinSequence extends Sequence | ||
{ | ||
/** | ||
* Create a new cross join sequence instance. | ||
* | ||
* @param array $sequences | ||
* @return void | ||
*/ | ||
public function __construct(...$sequences) | ||
{ | ||
$crossJoined = array_map( | ||
function ($a) { | ||
return array_merge(...$a); | ||
}, | ||
Arr::crossJoin(...$sequences), | ||
); | ||
|
||
parent::__construct(...$crossJoined); | ||
} | ||
} |
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