]> BookStack Code Mirror - bookstack/blob - app/Entities/Models/ContainerTrait.php
Merge pull request #5917 from BookStackApp/copy_references
[bookstack] / app / Entities / Models / ContainerTrait.php
1 <?php
2
3 namespace BookStack\Entities\Models;
4
5 use BookStack\Entities\Tools\EntityHtmlDescription;
6 use Illuminate\Database\Eloquent\Relations\HasOne;
7
8 /**
9  * @mixin Entity
10  */
11 trait ContainerTrait
12 {
13     public function descriptionInfo(): EntityHtmlDescription
14     {
15         return new EntityHtmlDescription($this);
16     }
17
18     /**
19      * @return HasOne<EntityContainerData, $this>
20      */
21     public function relatedData(): HasOne
22     {
23         return $this->hasOne(EntityContainerData::class, 'entity_id', 'id')
24             ->where('entity_type', '=', $this->getMorphClass());
25     }
26 }