X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/5d29d0cc7bb47cad7a662f1e6afc10cb97fe3ddd..refs/pull/5681/head:/app/References/Reference.php diff --git a/app/References/Reference.php b/app/References/Reference.php index a2a7bda10..df8a3a789 100644 --- a/app/References/Reference.php +++ b/app/References/Reference.php @@ -2,18 +2,21 @@ namespace BookStack\References; -use Illuminate\Database\Eloquent\Factories\HasFactory; +use BookStack\Permissions\Models\JointPermission; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\MorphTo; /** - * @property int $from_id + * @property int $from_id * @property string $from_type - * @property int $to_id + * @property int $to_id * @property string $to_type */ class Reference extends Model { + public $timestamps = false; + public function from(): MorphTo { return $this->morphTo('from'); @@ -23,4 +26,10 @@ class Reference extends Model { return $this->morphTo('to'); } + + public function jointPermissions(): HasMany + { + return $this->hasMany(JointPermission::class, 'entity_id', 'from_id') + ->whereColumn('references.from_type', '=', 'joint_permissions.entity_type'); + } }