master

laravel/framework

Last updated at: 29/12/2023 09:21

ConnectionResolverInterface.php

TLDR

This file defines the ConnectionResolverInterface interface in the Illuminate\Database namespace. It includes methods to get a database connection instance, get the default connection name, and set the default connection name.

Methods

connection($name = null): Illuminate\Database\ConnectionInterface

This method returns a database connection instance. It accepts an optional connection name parameter and returns an instance of Illuminate\Database\ConnectionInterface.

getDefaultConnection(): string

This method returns the default connection name as a string.

setDefaultConnection($name): void

This method sets the default connection name. It takes a string parameter $name and does not return any value.

<?php

namespace Illuminate\Database;

interface ConnectionResolverInterface
{
    /**
     * Get a database connection instance.
     *
     * @param  string|null  $name
     * @return \Illuminate\Database\ConnectionInterface
     */
    public function connection($name = null);

    /**
     * Get the default connection name.
     *
     * @return string
     */
    public function getDefaultConnection();

    /**
     * Set the default connection name.
     *
     * @param  string  $name
     * @return void
     */
    public function setDefaultConnection($name);
}