1010
1111class Schema
1212{
13+ public $ prefix ;
14+
1315 public static function __callStatic ($ method , $ parameters )
1416 {
17+ return (new self ())->{$ method }(...$ parameters );
18+ }
19+
20+ public function __call ($ method , $ parameters )
21+ {
22+ if ($ method === 'withPrefix ' ) {
23+ $ this ->prefix = $ parameters [0 ];
24+
25+ return $ this ;
26+ }
27+
1528 if (!method_exists (Blueprint::class, $ method )) {
1629 throw new RuntimeException ('Undefined method [ ' . $ method . '] called on Schema class. ' );
1730 }
@@ -21,29 +34,29 @@ public static function __callStatic($method, $parameters)
2134 }
2235
2336 if (\count ($ parameters ) > 1 && $ parameters [1 ] instanceof Closure) {
24- $ blueprint = self :: createBlueprint ($ parameters [0 ], $ method , $ parameters [1 ]);
37+ $ blueprint = $ this -> createBlueprint ($ parameters [0 ], $ method , $ parameters [1 ]);
2538 unset($ parameters [0 ], $ parameters [1 ]);
2639 } else {
27- $ blueprint = self :: createBlueprint ($ parameters [0 ], $ method );
40+ $ blueprint = $ this -> createBlueprint ($ parameters [0 ], $ method );
2841 unset($ parameters [0 ]);
2942 }
3043
3144 \call_user_func_array ([$ blueprint , $ method ], $ parameters );
3245
33- return self :: build ($ blueprint );
46+ return $ this -> build ($ blueprint );
3447 }
3548
36- public static function createBlueprint ($ schema , $ method , Closure $ callback = null )
49+ public function createBlueprint ($ schema , $ method , Closure $ callback = null )
3750 {
3851 return new Blueprint (
3952 $ schema ,
4053 $ method ,
41- Connection::getPrefix (),
54+ $ this -> prefix === '' ? Connection::getPrefix () : $ this -> prefix ,
4255 $ callback
4356 );
4457 }
4558
46- public static function build (Blueprint $ blueprint )
59+ public function build (Blueprint $ blueprint )
4760 {
4861 return $ blueprint ->build ();
4962 }
0 commit comments