]> BookStack Code Mirror - bookstack/blobdiff - app/References/Reference.php
Customization: Added parent tag classes
[bookstack] / app / References / Reference.php
index 5a490b5b52cdb4ab8f06858248075aa8e3c298a1..df8a3a78932eac36f6f17f4e7bb2b400c95cbaa9 100644 (file)
@@ -2,14 +2,15 @@
 
 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
@@ -25,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');
+    }
 }