1 | <?php |
||
2 | /** |
||
3 | * @package fisharebest/laravel-floats |
||
4 | * @copyright 2020 "Greg Roach" <[email protected]> |
||
5 | * @licence MIT |
||
6 | */ |
||
7 | namespace Fisharebest\LaravelFloats; |
||
8 | |||
9 | use Illuminate\Database\Connection; |
||
10 | use Illuminate\Database\MySqlConnection; |
||
11 | use Illuminate\Database\Schema\Builder; |
||
12 | use Illuminate\Support\Facades\Schema as BaseSchema; |
||
13 | |||
14 | class Schema extends BaseSchema |
||
15 | { |
||
16 | /** |
||
17 | * Get a schema builder instance for a connection. |
||
18 | * |
||
19 | * @param string $name |
||
20 | * |
||
21 | * @return Builder |
||
22 | */ |
||
23 | public static function connection($name) |
||
24 | { |
||
25 | /** @var Connection $connection */ |
||
26 | $connection = static::$app['db']->connection($name); |
||
27 | |||
28 | if ($connection instanceof MySqlConnection) { |
||
29 | $mysql_grammar = $connection->withTablePrefix(new MySqlGrammar()); |
||
30 | |||
31 | $connection->setSchemaGrammar($mysql_grammar); |
||
32 | |||
33 | $schema_builder = $connection->getSchemaBuilder(); |
||
34 | |||
35 | // Use our own version of Blueprint. |
||
36 | // Note that the constructor signature changed between Laravel 5.6 and 5.7, |
||
37 | // so we use variable arguments to work with both. |
||
38 | $schema_builder->blueprintResolver(function (...$args) { |
||
39 | return new Blueprint(/** @scrutinizer ignore-type */ ...$args); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
40 | }); |
||
41 | |||
42 | return $schema_builder; |
||
43 | } |
||
44 | |||
45 | return $connection->getSchemaBuilder(); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Get a schema builder instance for the default connection. |
||
50 | * |
||
51 | * @return Builder |
||
52 | */ |
||
53 | protected static function getFacadeAccessor() |
||
54 | { |
||
55 | return static::connection(null); |
||
56 | } |
||
57 | } |
||
58 |