BaseModel::joiningTable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Oscer\Cms\Core\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Support\Str;
7
8
abstract class BaseModel extends Model
9
{
10
    protected $guarded = [];
11
12
    /**
13
     * Get the table associated with the model.
14
     *
15
     * @return string
16
     */
17
    public function getTable()
18
    {
19
        return $this->table ?? 'cms_'.Str::snake(Str::pluralStudly(class_basename($this)));
20
    }
21
22
    /**
23
     * Get the joining table name for a many-to-many relation.
24
     *
25
     * @param  string  $related
26
     * @param  \Illuminate\Database\Eloquent\Model|null  $instance
27
     * @return string
28
     */
29
    public function joiningTable($related, $instance = null)
30
    {
31
        return 'cms_'.parent::joiningTable($related, $instance);
32
    }
33
}
34