'datetime:d.m.Y H:i:s', 'registered_at' => 'datetime:d.m.Y H:i:s', 'lastactive_at' => 'datetime:d.m.Y H:i:s' ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * @var Collection|mixed */ public Collection $forumPermissions; /** * @return HasOne */ public function profile(): HasOne { return $this->hasOne(Profile::class, 'user_uuid', 'uuid'); } /** * @return BelongsToMany */ public function groups(): BelongsToMany { return $this->belongsToMany(Group::class, 'users_has_groups', 'user_uuid', 'group_uuid'); } /** * @return HasMany */ public function invites(): HasMany { return $this->hasMany(Invite::class, 'created_uuid', 'uuid'); } /** * @param array $groups * @return bool */ public function isInGroup(array $groups): bool { $isInGroup = false; foreach($groups as $group) { $isInGroup = $this->groups->contains('group', $group); if($isInGroup) break; } return $isInGroup; } /** * @return Attribute */ public function emailEncrypted(): Attribute { return Attribute::make( get: fn($value) => decrypt($value), set: fn($value) => encrypt($value) ); } /** * @return Attribute */ public function emailHashed(): Attribute { return Attribute::make( set: fn($value) => hash('sha512', $value) ); } }