Tag   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 18
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A posts() 0 3 1
1
<?php
2
3
namespace Adminetic\Website\Models\Admin;
4
5
use Illuminate\Database\Eloquent\Factories\HasFactory;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Database\Eloquent\Relations\MorphToMany;
8
9
class Tag extends Model
10
{
11
    use HasFactory;
12
    protected $fillable = ['name', 'slug'];
13
14
    public function __construct(array $attributes = [])
15
    {
16
        $this->table = config('website.table_prefix', 'website').'_tags';
17
18
        parent::__construct($attributes);
19
    }
20
21
    /**
22
     * Get all of the posts that are assigned this tag.
23
     */
24
    public function posts(): MorphToMany
25
    {
26
        return $this->morphedByMany(Post::class, 'taggable');
27
    }
28
}
29