فهرست منبع

Fix PM\PTopic model

for #5
Visman 3 سال پیش
والد
کامیت
51a03d6c13
1فایلهای تغییر یافته به همراه6 افزوده شده و 5 حذف شده
  1. 6 5
      app/Models/PM/PTopic.php

+ 6 - 5
app/Models/PM/PTopic.php

@@ -195,14 +195,15 @@ class PTopic extends DataModel
 
     protected function user(string $prx): User
     {
-        $user = $this->c->users->load($this->{"{$prx}_id"});
+        if (
+            $this->{"{$prx}_id"} < 1
+            || ! ($user = $this->c->users->load($this->{"{$prx}_id"})) instanceof User
+        ) {
+            $user = $this->c->users->guest(['username' => $this->{$prx}]);
+        }
 
         if (! $user instanceof User) {
             throw new RuntimeException('User model could not be loaded ');
-        } elseif ($user->isGuest) {
-            $user = clone $user;
-
-            $user->__username = $this->{$prx};
         }
 
         return $user;