Update Post model
This commit is contained in:
parent
1d72e0a018
commit
281a9b29f8
1 changed files with 6 additions and 10 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue