Browse Source

Update Post\Model

There is a need to think about how to unbind id =1 from the guest :(
Visman 4 years ago
parent
commit
2af02b0286
1 changed files with 9 additions and 2 deletions
  1. 9 2
      app/Models/Post/Model.php

+ 9 - 2
app/Models/Post/Model.php

@@ -60,9 +60,16 @@ class Model extends DataModel
     {
         $user = $this->c->users->load($this->poster_id);
 
+        if (
+            ! $user instanceof User
+            && 1 !== $this->poster_id // ???? может сменить id гостя?
+        ) {
+            $user = $this->c->users->load(1);
+        }
+
         if (! $user instanceof User) {
-            throw new RuntimeException('No user data in post number ' . $this->id);
-        } elseif (1 === $this->poster_id) {
+            throw new RuntimeException("No user data in post number {$this->id}");
+        } elseif ($user->isGuest) {
             $user = clone $user;
 
             $user->__email        = $this->poster_email;