]> BookStack Code Mirror - bookstack/blob - app/Users/Models/HasCreatorAndUpdater.php
Merge branch 'v25-07' into development
[bookstack] / app / Users / Models / HasCreatorAndUpdater.php
1 <?php
2
3 namespace BookStack\Users\Models;
4
5 use Illuminate\Database\Eloquent\Relations\BelongsTo;
6
7 /**
8  * @property int $created_by
9  * @property int $updated_by
10  * @property ?User $createdBy
11  * @property ?User $updatedBy
12  */
13 trait HasCreatorAndUpdater
14 {
15     /**
16      * Relation for the user that created this entity.
17      */
18     public function createdBy(): BelongsTo
19     {
20         return $this->belongsTo(User::class, 'created_by');
21     }
22
23     /**
24      * Relation for the user that updated this entity.
25      */
26     public function updatedBy(): BelongsTo
27     {
28         return $this->belongsTo(User::class, 'updated_by');
29     }
30
31     public function getOwnerFieldName(): string
32     {
33         return 'created_by';
34     }
35 }