1 | <?php namespace Cviebrock\EloquentTaggable\Models; |
||
13 | class Tag extends Model |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @inheritdoc |
||
18 | */ |
||
19 | protected $table; |
||
20 | |||
21 | /** |
||
22 | * @inheritdoc |
||
23 | */ |
||
24 | protected $primaryKey = 'tag_id'; |
||
25 | |||
26 | /** |
||
27 | * @inheritdoc |
||
28 | */ |
||
29 | protected $fillable = [ |
||
30 | 'name', |
||
31 | 'normalized', |
||
32 | ]; |
||
33 | |||
34 | /** |
||
35 | * @inheritdoc |
||
36 | */ |
||
37 | public function __construct(array $attributes = []) |
||
48 | 23 | ||
49 | 23 | /** |
|
50 | * Set the name attribute on the model. |
||
51 | * |
||
52 | * @param string $value |
||
53 | */ |
||
54 | public function setNameAttribute($value) |
||
60 | |||
61 | /** |
||
62 | * Scope to find tags by name. |
||
63 | * |
||
64 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
65 | * @param $value |
||
66 | * |
||
67 | * @return \Illuminate\Database\Eloquent\Builder |
||
68 | */ |
||
69 | public function scopeByName(Builder $query, string $value): Builder |
||
75 | |||
76 | /** |
||
77 | * @inheritdoc |
||
78 | */ |
||
79 | public function getRelationValue($key) |
||
97 | |||
98 | /** |
||
99 | * Get the inverse of the polymorphic relation, via an attribute |
||
100 | * defining the type of models to return. |
||
101 | * |
||
102 | * @param string $class |
||
103 | * |
||
104 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
105 | */ |
||
106 | protected function taggedModels(string $class): MorphToMany |
||
112 | |||
113 | /** |
||
114 | * Find the tag with the given name. |
||
115 | * |
||
116 | * @param string $value |
||
117 | * |
||
118 | * @return static|null |
||
119 | */ |
||
120 | public static function findByName(string $value) |
||
124 | |||
125 | /** |
||
126 | * @inheritdoc |
||
127 | */ |
||
128 | public function __toString(): string |
||
132 | |||
133 | } |
||
134 |