framework/src/Core/Users/Guest.php

46 lines
953 B
PHP
Raw Normal View History

2015-08-27 01:40:18 +02:00
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
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;
}
}