Passed
Pull Request — master (#165)
by Anton
03:20
created

Model::getConnectionName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of Laravel Love.
5
 *
6
 * (c) Anton Komarev <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Cog\Laravel\Love\Support\Database\Eloquent;
15
16
use Illuminate\Database\Eloquent\Model as IlluminateModel;
17
use Illuminate\Support\Facades\Config;
18
19
abstract class Model extends IlluminateModel
20
{
21
    /**
22
     * Get the current connection name for the model.
23
     *
24
     * @return null|string
25
     */
26
    public function getConnectionName(): ?string
27
    {
28
        return Config::get('love.storage.database.connection');
29
    }
30
31
    public function getTable(): string
32
    {
33
        return Config::get("love.storage.database.tables.{$this->table}")
34
            ?? $this->table;
35
    }
36
}
37