File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 7
7
use Illuminate \Database \Connection ;
8
8
use Illuminate \Database \Schema \Blueprint as SchemaBlueprint ;
9
9
use MongoDB \Collection ;
10
+ use ReflectionMethod ;
10
11
11
12
use function array_flip ;
12
13
use function implode ;
18
19
19
20
class Blueprint extends SchemaBlueprint
20
21
{
22
+ private static bool $ hasConnectionInConstructor ;
23
+
21
24
/**
22
25
* The MongoDB connection object for this blueprint.
23
26
*/
@@ -40,9 +43,19 @@ class Blueprint extends SchemaBlueprint
40
43
/**
41
44
* Create a new schema blueprint.
42
45
*/
43
- public function __construct (Connection $ connection , string $ collection )
46
+ public function __construct (Connection $ connection , string $ collection, ? Closure $ callback = null )
44
47
{
45
- parent ::__construct ($ connection , $ collection );
48
+ // Parent constructor signature was changed in Laravel 12
49
+ // https://github.com/laravel/framework/commit/f29df4740d724f1c36385c9989569e3feb9422df#diff-68f714a9f1b751481b993414d3f1300ad55bcef12084ec0eb8f47f350033c24bR107
50
+ self ::$ hasConnectionInConstructor ??= (new ReflectionMethod (parent ::class, '__construct ' ))->getParameters ()[0 ]->getName () === 'connection ' ;
51
+
52
+ if (self ::$ hasConnectionInConstructor ) {
53
+ // Laravel 12 and after
54
+ parent ::__construct ($ connection , $ collection , $ callback );
55
+ } else {
56
+ // Laravel 11 and before
57
+ parent ::__construct ($ collection , $ callback );
58
+ }
46
59
47
60
$ this ->connection = $ connection ;
48
61
You can’t perform that action at this time.
0 commit comments