]> _ Git - psq.git/commitdiff
fix subscrpition
authorLouis Jeckel <louis.jeckel@outlook.cm>
Thu, 27 Aug 2020 16:53:13 +0000 (18:53 +0200)
committerLouis Jeckel <louis.jeckel@outlook.cm>
Thu, 27 Aug 2020 16:53:13 +0000 (18:53 +0200)
app/Policies/PdfFilePolicy.php
app/User.php

index 729719c3781ca741a3c2f00857980d558dd84e14..8c2d5bcde885e3899517b5aefd26ba6e515b05cf 100644 (file)
@@ -49,7 +49,7 @@ class PdfFilePolicy
         }
 
 
-        if($pdfFile->is_free || ($user instanceof \App\User ? $user->isSubscribed : false)) {
+        if($pdfFile->is_free || ($user instanceof \App\User ? $user->hasValidSubscription() : false)) {
             return true;
         }
 
index b8d907efb53a1ad02fef485631d0a6b1c06387e6..e32fe393db8016acfe1e073931db24afc4b353f2 100644 (file)
@@ -204,6 +204,25 @@ class User extends Authenticatable implements MustVerifyEmail
         return in_array($this->status, $status, true);
     }
 
+    /**
+     * @return bool
+     * @todo Add indiv subscription plans
+     */
+    public function hasValidSubscription(): bool
+    {
+        return $this->orgIsSubscribed();
+    }
+
+    /**
+     * @return bool
+     * Checks if affiliated organization has valid subscription
+     */
+    public function orgIsSubscribed(): bool
+    {
+        return ($o = $this->organization) === null ?
+            false:
+            $o->isSubscribed();
+    }
 
 
 
@@ -285,13 +304,19 @@ class User extends Authenticatable implements MustVerifyEmail
 
     /**
      * @return bool
-     * Checks if affiliated organization has valid subscription
      */
     public function getOrgIsSubscribedAttribute(): bool
     {
-        return ($o = $this->organization) === null ?
-            false:
-            $o->isSubscribed();
+        return $this->orgIsSubscribed();
+    }
+
+    /**
+     * @return bool
+     * Checks if has any valid subscription
+     */
+    public function geHasValidSubscriptionAttribute(): bool
+    {
+        return $this->hasValidSubscription();
     }