|
2
|
1 <?php
|
|
|
2
|
|
|
3 namespace Libraries;
|
|
|
4
|
|
|
5 use Illuminate\Database\Schema\Builder;
|
|
|
6 use Illuminate\Support\Facades\Schema as BaseSchema;
|
|
|
7
|
|
|
8 class MySchema extends BaseSchema
|
|
|
9 {
|
|
|
10 /**
|
|
|
11 * Get a schema builder instance for a connection.
|
|
|
12 *
|
|
|
13 * @param string|null $name
|
|
|
14 */
|
|
|
15 public static function connection($name): Builder
|
|
|
16 {
|
|
|
17 return self::customizedSchemaBuilder($name);
|
|
|
18 }
|
|
|
19
|
|
|
20 /**
|
|
|
21 * Retrieves an instance of the schema `Builder` with a customized `Blueprint` class.
|
|
|
22 */
|
|
|
23 public static function customizedSchemaBuilder(?string $name = null): Builder
|
|
|
24 {
|
|
|
25 /** @var Builder $builder */
|
|
|
26 $builder = static::$app['db']->connection($name)->getSchemaBuilder();
|
|
|
27
|
|
|
28 $builder->blueprintResolver(static fn ($table, $callback, $prefix) => new MyBlueprint($table, $callback, $prefix));
|
|
|
29
|
|
|
30 return $builder;
|
|
|
31 }
|
|
|
32 }
|