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