]> BookStack Code Mirror - bookstack/blobdiff - app/References/Reference.php
Perms: Fixed some issues made when adding transactions
[bookstack] / app / References / Reference.php
index a2a7bda103fe4cdfebfb593d70b5c79c95d067a1..df8a3a78932eac36f6f17f4e7bb2b400c95cbaa9 100644 (file)
@@ -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');
+    }
 }