Update Post model

This commit is contained in:
Visman 2021-12-04 19:27:52 +07:00
parent 1d72e0a018
commit 281a9b29f8

View file

@ -64,22 +64,18 @@ class Post extends DataModel
*/
protected function getuser(): User
{
$user = $this->c->users->load($this->poster_id);
if (
! $user instanceof User
&& 1 !== $this->poster_id // ???? может сменить id гостя?
$this->poster_id < 1
|| ! ($user = $this->c->users->load($this->poster_id)) instanceof User
) {
$user = $this->c->users->load(1);
$user = $this->c->users->guest([
'username' => $this->poster,
'email' => $this->poster_email,
]);
}
if (! $user instanceof User) {
throw new RuntimeException("No user data in post number {$this->id}");
} elseif ($user->isGuest) {
$user = clone $user;
$user->__email = $this->poster_email;
$user->__username = $this->poster;
}
return $user;