32 lines
882 B
PHP
32 lines
882 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace Database\ArcadiaReplicate;
|
||
|
|
|
||
|
|
use Illuminate\Database\Connection;
|
||
|
|
use Illuminate\Support\Facades\DB;
|
||
|
|
use Infra\Config\ArcadiaStorageConfig;
|
||
|
|
|
||
|
|
trait IdentifiesTableOrView
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Nom complet qualifié de la table (ex: 'REFP.INCO' sous Oracle, 'INCO' sous SQLite/MySQL).
|
||
|
|
*/
|
||
|
|
public static function table(Connection | string | null $connection = null): string
|
||
|
|
{
|
||
|
|
if ($connection instanceof Connection) {
|
||
|
|
$driver = $connection->getDriverName();
|
||
|
|
} else {
|
||
|
|
$connectionName = $connection ?? resolve(ArcadiaStorageConfig::class)->databaseConnection;
|
||
|
|
$driver = DB::connection($connectionName)->getDriverName();
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($driver === 'oracle') {
|
||
|
|
return static::schemaName() . '.' . static::name();
|
||
|
|
}
|
||
|
|
|
||
|
|
return static::name();
|
||
|
|
}
|
||
|
|
}
|