4
4
5
5
namespace MongoDB \Laravel \Schema ;
6
6
7
- use Closure ;
8
- use Illuminate \Database \Connection ;
9
- use Illuminate \Database \Schema \Blueprint as SchemaBlueprint ;
7
+ use Illuminate \Database \Schema \Blueprint as BaseBlueprint ;
10
8
use MongoDB \Collection ;
11
- use ReflectionMethod ;
9
+ use MongoDB \ Laravel \ Connection ;
12
10
13
11
use function array_flip ;
14
12
use function implode ;
18
16
use function is_string ;
19
17
use function key ;
20
18
21
- class Blueprint extends SchemaBlueprint
19
+ /** @property Connection $connection */
20
+ class Blueprint extends BaseBlueprint
22
21
{
23
- private static bool $ hasConnectionInConstructor ;
24
-
25
- /**
26
- * The MongoDB connection object for this blueprint.
27
- */
28
- protected Connection $ connection ;
22
+ // Import $connection property and constructor for Laravel 12 compatibility
23
+ use BlueprintLaravelCompatibility;
29
24
30
25
/**
31
26
* The MongoDB collection object for this blueprint.
32
- * Type added in Laravel 12.
33
27
*
34
28
* @var Collection
35
29
*/
36
- protected Collection $ collection ;
30
+ protected $ collection ;
37
31
38
32
/**
39
33
* Fluent columns.
@@ -42,28 +36,6 @@ class Blueprint extends SchemaBlueprint
42
36
*/
43
37
protected $ columns = [];
44
38
45
- /**
46
- * Create a new schema blueprint.
47
- */
48
- public function __construct (Connection $ connection , string $ collection , ?Closure $ callback = null )
49
- {
50
- // Parent constructor signature was changed in Laravel 12
51
- // https://github.com/laravel/framework/commit/f29df4740d724f1c36385c9989569e3feb9422df#diff-68f714a9f1b751481b993414d3f1300ad55bcef12084ec0eb8f47f350033c24bR107
52
- self ::$ hasConnectionInConstructor ??= (new ReflectionMethod (parent ::class, '__construct ' ))->getParameters ()[0 ]->getName () === 'connection ' ;
53
-
54
- if (self ::$ hasConnectionInConstructor ) {
55
- // Laravel 12 and after
56
- parent ::__construct ($ connection , $ collection , $ callback );
57
- } else {
58
- // Laravel 11 and before
59
- parent ::__construct ($ collection , $ callback );
60
- }
61
-
62
- $ this ->connection = $ connection ;
63
-
64
- $ this ->collection = $ this ->connection ->getCollection ($ collection );
65
- }
66
-
67
39
/** @inheritdoc */
68
40
public function index ($ columns = null , $ name = null , $ algorithm = null , $ options = [])
69
41
{
0 commit comments