annotate src/Database/MySchema.php @ 4:84c75d9d90be

Changing usage to be bootstrap 5, not everything is reviewed but it's been started
author luka
date Tue, 19 Aug 2025 20:33:35 -0400
parents b44434aaa767
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
1 <?php
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
2
4
84c75d9d90be Changing usage to be bootstrap 5, not everything is reviewed but it's been started
luka
parents: 2
diff changeset
3 namespace Wizard\Framework\Database;
2
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
4
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
5 use Illuminate\Database\Schema\Builder;
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
6 use Illuminate\Support\Facades\Schema as BaseSchema;
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
7
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
8 class MySchema extends BaseSchema
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
9 {
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
10 /**
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
11 * Get a schema builder instance for a connection.
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
12 *
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
13 * @param string|null $name
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
14 */
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
15 public static function connection($name): Builder
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
16 {
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
17 return self::customizedSchemaBuilder($name);
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
18 }
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
19
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
20 /**
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
21 * Retrieves an instance of the schema `Builder` with a customized `Blueprint` class.
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
22 */
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
23 public static function customizedSchemaBuilder(?string $name = null): Builder
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
24 {
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
25 /** @var Builder $builder */
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
26 $builder = static::$app['db']->connection($name)->getSchemaBuilder();
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
27
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
28 $builder->blueprintResolver(static fn ($table, $callback, $prefix) => new MyBlueprint($table, $callback, $prefix));
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
29
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
30 return $builder;
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
31 }
b44434aaa767 Moving around the components.
luka
parents:
diff changeset
32 }