$sites * User's associated sites. * * @see \Uwil\LaravelBackend\Models\User For all other properties and methods. */ class User extends BackendUser { /** * Except some fields to the user model fill. * * @var list */ #[\Override] public static $exceptFromFill = [ 'gitlab_id', 'sites', ]; /** * Get relations to include in the cache. * * @return list */ #[\Override] public static function getCacheRelations(): array { return ['gitlabUser', 'sites']; } /** * Relations should be share to views. * * @return array */ #[\Override] public static function getPropsRelations(): array { return [ 'gitlabUser', 'sites' => fn ($q) => $q->withoutGlobalScope(SoftDeletingScope::class), ]; } /** * Get the password for authentication. * Retrieves the hashed password from the related user_passwords table. */ #[\Override] public function getAuthPassword(): string { return $this->userPassword()->value('password') ?? ''; } /** * Send the password reset notification to the user. * * @param string $token * * @phpcs:disable */ #[\Override] public function sendPasswordResetNotification($token): void { // @phpcs:enable $url = sprintf( '%s?email=%s', url(route(config('uwil-backend.routes.name') . 'reset-password', ['token' => $token], false)), urlencode($this->getEmailForPasswordReset()) ); Mail::send(new LinkResetPasswordMail($url, $this)); } // * RELATIONSHIPS. /** * Get the user's associated password. * * @return \Illuminate\Database\Eloquent\Relations\HasOne<\App\Models\UserPassword,$this> */ public function userPassword(): HasOne { return $this->hasOne(UserPassword::class); } /** * Get the user's associated gitlab id. * * @return \Illuminate\Database\Eloquent\Relations\HasOne<\App\Models\GitlabUser,$this> */ public function gitlabUser(): HasOne { return $this->hasOne(GitlabUser::class); } /** * Get sites associated to the user. * * @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\App\Models\Site,$this,\Illuminate\Database\Eloquent\Relations\MorphPivot,'pivot'> */ public function sites(): MorphToMany { return $this->morphToMany( Site::class, 'sitable', 'sitables', 'sitable_id', 'site_id', )->withPivot('created_at'); } }