/** * 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']; }
/** * Find a user by ID, optionally making sure it is visible to a certain * user, or throw an exception. * * @param int $id * @param User $actor * @return Group * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException */ public function findOrFail($id, User $actor = null) { $query = Group::where('id', $id); return $this->scopeVisibleTo($query, $actor)->firstOrFail(); }