Ver código fonte

Update PBlock.php

Visman 3 anos atrás
pai
commit
d5dd1ca61c
1 arquivos alterados com 22 adições e 0 exclusões
  1. 22 0
      app/Models/PM/PBlock.php

+ 22 - 0
app/Models/PM/PBlock.php

@@ -39,6 +39,8 @@ class PBlock extends Model
 
     public function init(User $user): void
     {
+        $this->setAttrs([]);
+
         $this->repository = [];
         $this->user       = $user;
 
@@ -103,4 +105,24 @@ class PBlock extends Model
 
         return false !== $this->c->DB->exec($query, $vars);
     }
+
+    /**
+     * Возвращает массив заблокированных пользователей
+     */
+    protected function getlist(): array
+    {
+        return isset($this->repository[$this->user->id])
+            ? $this->c->users->loadByIds($this->repository[$this->user->id])
+            : [];
+    }
+
+    /**
+     * Возращает статус возможности блокировки пользователя
+     */
+    public function canBlock(User $user): bool
+    {
+        return $this->user->id !== $user->id
+            && ! $user->isAdmin
+            && ! $user->isGuest;
+    }
 }