]> BookStack Code Mirror - bookstack/blob - app/Actions/Tag.php
Revamped workings of WYSIWYG code blocks
[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 /**
10  * @property int    $id
11  * @property string $name
12  * @property string $value
13  * @property int    $order
14  */
15 class Tag extends Model
16 {
17     use HasFactory;
18
19     protected $fillable = ['name', 'value', 'order'];
20     protected $hidden = ['id', 'entity_id', 'entity_type', 'created_at', 'updated_at'];
21
22     /**
23      * Get the entity that this tag belongs to.
24      */
25     public function entity(): MorphTo
26     {
27         return $this->morphTo('entity');
28     }
29
30     /**
31      * Get a full URL to start a tag name search for this tag name.
32      */
33     public function nameUrl(): string
34     {
35         return url('/search?term=%5B' . urlencode($this->name) . '%5D');
36     }
37
38     /**
39      * Get a full URL to start a tag name and value search for this tag's values.
40      */
41     public function valueUrl(): string
42     {
43         return url('/search?term=%5B' . urlencode($this->name) . '%3D' . urlencode($this->value) . '%5D');
44     }
45 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.