2015-08-27 01:40:18 +02:00
|
|
|
<?php
|
2015-08-26 16:18:58 +09:30
|
|
|
/*
|
|
|
|
* 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;
|
2015-02-24 20:33:18 +10:30
|
|
|
|
2015-07-04 19:30:58 +09:30
|
|
|
use Flarum\Core\Groups\Group;
|
|
|
|
|
2015-02-24 20:33:18 +10:30
|
|
|
class Guest extends User
|
|
|
|
{
|
2015-07-04 12:24:48 +09:30
|
|
|
/**
|
|
|
|
* Override the ID of this user, as a guest does not have an ID.
|
|
|
|
*
|
|
|
|
* @var int
|
|
|
|
*/
|
2015-02-24 20:33:18 +10:30
|
|
|
public $id = 0;
|
|
|
|
|
|
|
|
/**
|
2015-07-04 12:24:48 +09:30
|
|
|
* Get the guest's group, containing only the 'guests' group model.
|
2015-02-24 20:33:18 +10:30
|
|
|
*
|
|
|
|
* @return \Flarum\Core\Models\Group
|
|
|
|
*/
|
2015-05-19 01:03:12 +02:00
|
|
|
public function getGroupsAttribute()
|
|
|
|
{
|
|
|
|
if (! isset($this->attributes['groups'])) {
|
|
|
|
$this->attributes['groups'] = $this->relations['groups'] = Group::where('id', Group::GUEST_ID)->get();
|
|
|
|
}
|
2015-02-24 20:33:18 +10:30
|
|
|
|
2015-05-19 01:03:12 +02:00
|
|
|
return $this->attributes['groups'];
|
|
|
|
}
|
2015-02-24 20:33:18 +10:30
|
|
|
|
|
|
|
/**
|
2015-07-04 12:24:48 +09:30
|
|
|
* {@inheritdoc}
|
2015-02-24 20:33:18 +10:30
|
|
|
*/
|
2015-07-04 12:24:48 +09:30
|
|
|
public function isGuest()
|
2015-05-19 01:03:12 +02:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2015-02-24 20:33:18 +10:30
|
|
|
}
|