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