return $this->roles->pluck('name')->contains($role);
}
+ /**
+ * Check if the user has a role.
+ * @param $role
+ * @return mixed
+ */
+ public function hasSystemRole($role)
+ {
+ return $this->roles->pluck('system_name')->contains($role);
+ }
+
/**
* Get all permissions belonging to a the current user.
* @param bool $cache
*/
public function getAvatar($size = 50)
{
- if ($this->image_id === 0 || $this->image_id === '0' || $this->image_id === null) return baseUrl('/user_avatar.png');
- return baseUrl($this->avatar->getThumb($size, $size, false));
+ $default = baseUrl('/user_avatar.png');
+ $imageId = $this->image_id;
+ if ($imageId === 0 || $imageId === '0' || $imageId === null) return $default;
+
+ try {
+ $avatar = $this->avatar ? baseUrl($this->avatar->getThumb($size, $size, false)) : $default;
+ } catch (\Exception $err) {
+ $avatar = $default;
+ }
+ return $avatar;
}
/**