framework/src/Core/Users/Guest.php

36 lines
737 B
PHP
Raw Normal View History

<?php namespace Flarum\Core\Users;
use Flarum\Core\Groups\Group;
class Guest extends User
{
/**
* Override the ID of this user, as a guest does not have an ID.
*
* @var int
*/
public $id = 0;
/**
* Get the guest's group, containing only the 'guests' group model.
*
* @return \Flarum\Core\Models\Group
*/
public function getGroupsAttribute()
{
if (! isset($this->attributes['groups'])) {
$this->attributes['groups'] = $this->relations['groups'] = Group::where('id', Group::GUEST_ID)->get();
}
return $this->attributes['groups'];
}
/**
* {@inheritdoc}
*/
public function isGuest()
{
return true;
}
}