view src/Database/MySchema.php @ 2:b44434aaa767

Moving around the components. Made a big step in the right direction with the Builder and named joins being accessible.
author luka
date Wed, 18 Jun 2025 22:28:47 -0400
parents
children 84c75d9d90be
line wrap: on
line source

<?php

namespace Libraries;

use Illuminate\Database\Schema\Builder;
use Illuminate\Support\Facades\Schema as BaseSchema;

class MySchema extends BaseSchema
{
    /**
     * Get a schema builder instance for a connection.
     *
     * @param  string|null  $name
     */
    public static function connection($name): Builder
    {
        return self::customizedSchemaBuilder($name);
    }

    /**
     * Retrieves an instance of the schema `Builder` with a customized `Blueprint` class.
     */
    public static function customizedSchemaBuilder(?string $name = null): Builder
    {
        /** @var Builder $builder */
        $builder = static::$app['db']->connection($name)->getSchemaBuilder();

        $builder->blueprintResolver(static fn ($table, $callback, $prefix) => new MyBlueprint($table, $callback, $prefix));

        return $builder;
    }
}