Search code examples
phplaravelframeworkslaravel-5laravel-facade

Searching for Schema:table static method definition in Laravel Framework


I'm trying to understand PHP Laravel Framework. Whend dealing with databases, we use Schema::table to create a table in the database. Searching in my application I find the only definition is

<?php namespace Illuminate\Support\Facades;

/**
 * @see \Illuminate\Database\Schema\Builder
 */
class Schema extends Facade {

    /**
     * Get a schema builder instance for a connection.
     *
     * @param  string  $name
     * @return \Illuminate\Database\Schema\Builder
     */
    public static function connection($name)
    {
        return static::$app['db']->connection($name)->getSchemaBuilder();
    }

    /**
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor()
    {
        return static::$app['db']->connection()->getSchemaBuilder();
    }

}

but there is not a table static method neither in Schema class or in Facade class.

What piece I'm missing?


Solution

  • Schema here is only facade. Method table() and other methods from Schema can be found in file: \vendor\laravel\framework\src\Illuminate\Database\Schema\Builder.php .

    Other methods can be found in \vendor\laravel\framework\src\Illuminate\Database\Schema\Blueprint.php

    You should always look at Facade Class Reference to know what class you are really using.