]> BookStack Code Mirror - bookstack/blob - app/Actions/Tag.php
Laravel 8 shift squash & merge (#3029)
[bookstack] / app / Actions / Tag.php
1 <?php
2
3 namespace BookStack\Actions;
4
5 use BookStack\Model;
6 use Illuminate\Database\Eloquent\Factories\HasFactory;
7 use Illuminate\Database\Eloquent\Relations\MorphTo;
8
9 class Tag extends Model
10 {
11     use HasFactory;
12
13     protected $fillable = ['name', 'value', 'order'];
14     protected $hidden = ['id', 'entity_id', 'entity_type', 'created_at', 'updated_at'];
15
16     /**
17      * Get the entity that this tag belongs to.
18      */
19     public function entity(): MorphTo
20     {
21         return $this->morphTo('entity');
22     }
23
24     /**
25      * Get a full URL to start a tag name search for this tag name.
26      */
27     public function nameUrl(): string
28     {
29         return url('/search?term=%5B' . urlencode($this->name) . '%5D');
30     }
31
32     /**
33      * Get a full URL to start a tag name and value search for this tag's values.
34      */
35     public function valueUrl(): string
36     {
37         return url('/search?term=%5B' . urlencode($this->name) . '%3D' . urlencode($this->value) . '%5D');
38     }
39 }