File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 77use Illuminate \Database \Connection ;
88use Illuminate \Database \Schema \Blueprint as SchemaBlueprint ;
99use MongoDB \Collection ;
10+ use ReflectionMethod ;
1011
1112use function array_flip ;
1213use function implode ;
1819
1920class Blueprint extends SchemaBlueprint
2021{
22+ private static bool $ hasConnectionInConstructor ;
23+
2124 /**
2225 * The MongoDB connection object for this blueprint.
2326 */
@@ -40,9 +43,19 @@ class Blueprint extends SchemaBlueprint
4043 /**
4144 * Create a new schema blueprint.
4245 */
43- public function __construct (Connection $ connection , string $ collection )
46+ public function __construct (Connection $ connection , string $ collection, ? Closure $ callback = null )
4447 {
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+ }
4659
4760 $ this ->connection = $ connection ;
4861
You can’t perform that action at this time.
0 commit comments