]> BookStack Code Mirror - bookstack/blobdiff - app/Actions/View.php
Added examples, updated docs for image gallery api endpoints
[bookstack] / app / Actions / View.php
index 16961bd914bef8b29fc659d6f689fd7f56b99376..706467133fa5ecc36ec6aaeaecd9e48f88595f48 100644 (file)
@@ -2,8 +2,10 @@
 
 namespace BookStack\Actions;
 
+use BookStack\Auth\Permissions\JointPermission;
 use BookStack\Interfaces\Viewable;
 use BookStack\Model;
+use Illuminate\Database\Eloquent\Relations\HasMany;
 use Illuminate\Database\Eloquent\Relations\MorphTo;
 
 /**
@@ -28,6 +30,12 @@ class View extends Model
         return $this->morphTo();
     }
 
+    public function jointPermissions(): HasMany
+    {
+        return $this->hasMany(JointPermission::class, 'entity_id', 'viewable_id')
+            ->whereColumn('views.viewable_type', '=', 'joint_permissions.entity_type');
+    }
+
     /**
      * Increment the current user's view count for the given viewable model.
      */