Reputation: 301
I use DB facade. I see it can use in DB::connection from Illuminate\Database\DatabaseManager and DB::select from Illuminate\Database\Connection.
I don't understand how one facade can apply two serivce?
Thank you for your asking!
Upvotes: 1
Views: 226
Reputation: 9465
One Facade can point to multiple classes for different methods. This is possible through the magic method __call.
Here's the __call
method of the DatabaseManager
class:
/**
* Dynamically pass methods to the default connection.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
return $this->connection()->$method(...$parameters);
}
The DB
facade points to the DatabaseManager
class and if the method is not found the DatabaseManager
then forwards the call to the Connection
class.
Upvotes: 1