Illuminate\Database\Eloquent\Model::on PHP Method

on() public static method

Begin querying the model on a given connection.
public static on ( string | null $connection = null ) : Builder
$connection string | null
return Builder
    public static function on($connection = null)
    {
        // First we will just create a fresh instance of this model, and then we can
        // set the connection on the model so that it is be used for the queries
        // we execute, as well as being set on each relationship we retrieve.
        $instance = new static();
        $instance->setConnection($connection);
        return $instance->newQuery();
    }
Model