Tagged   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 9
c 2
b 1
f 0
dl 0
loc 32
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A taggable() 0 3 1
A tag() 0 4 1
A __construct() 0 5 1
1
<?php namespace Conner\Tagging\Model;
2
3
use Conner\Tagging\TaggingUtility;
4
use Illuminate\Database\Eloquent\Model;
5
6
/**
7
 * @package Conner\Tagging\Model
8
 *
9
 * @property integer id
10
 * @property string taggable_id
11
 * @property string taggable_type
12
 * @property string tag_name
13
 * @property string tag_slug
14
 * @property Tag tag
15
 */
16
class Tagged extends Model
17
{
18
    protected $table = 'tagging_tagged';
19
    public $timestamps = false;
20
    protected $fillable = ['tag_name', 'tag_slug'];
21
22
    public function __construct(array $attributes = [])
23
    {
24
        parent::__construct($attributes);
25
26
        $this->connection = config('tagging.connection');
27
    }
28
29
    /**
30
     * Morph to the tag
31
     *
32
     * @return \Illuminate\Database\Eloquent\Relations\MorphTo
33
     */
34
    public function taggable()
35
    {
36
        return $this->morphTo();
37
    }
38
39
    /**
40
     * Get instance of tag linked to the tagged value
41
     *
42
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
43
     */
44
    public function tag()
45
    {
46
        $model = TaggingUtility::tagModelString();
47
        return $this->belongsTo($model, 'tag_slug', 'slug');
48
    }
49
50
}
51