Tag::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
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