<?php /** * Models that store data in Postgres */ namespace App\Traits; trait UsePostgres { /** * Resolve a connection instance. * We need to do this, because our relations are in pgsql and somehow loading a relation changes this models * connection information. Using protected $connection is not enough. * * @param string|null $connection */ public static function resolveConnection($connection = null) { return static::$resolver->connection('pgsql'); } }