20-02-2026
This commit is contained in:
parent
854ce02bf6
commit
4d6b4930b2
128 changed files with 18247 additions and 2093 deletions
|
|
@ -2,10 +2,13 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\UserOrigin;
|
||||
use App\Notifications\CustomResetPasswordNotification;
|
||||
use App\Notifications\CustomVerifyEmailNotification;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
|
@ -13,13 +16,11 @@ use Illuminate\Support\Str;
|
|||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
class User extends Authenticatable implements MustVerifyEmail
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasApiTokens, HasFactory, HasRoles, Notifiable, TwoFactorAuthenticatable, SoftDeletes;
|
||||
use HasApiTokens, HasFactory, HasRoles, Notifiable, SoftDeletes, TwoFactorAuthenticatable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
|
@ -28,6 +29,8 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||
*/
|
||||
protected $fillable = [
|
||||
'partner_id',
|
||||
'hub_id',
|
||||
'origin',
|
||||
'name',
|
||||
'display_name',
|
||||
'email',
|
||||
|
|
@ -56,6 +59,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||
'email_verified_at' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
'origin' => UserOrigin::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -64,6 +68,14 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||
return $this->belongsTo(Partner::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Direkte Hub-Zuordnung des Users (für schnelle Queries).
|
||||
*/
|
||||
public function hub(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Hub::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the registration code used by this user
|
||||
*/
|
||||
|
|
@ -79,7 +91,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||
{
|
||||
return Str::of($this->name)
|
||||
->explode(' ')
|
||||
->map(fn(string $name) => Str::of($name)->substr(0, 1))
|
||||
->map(fn (string $name) => Str::of($name)->substr(0, 1))
|
||||
->implode('');
|
||||
}
|
||||
|
||||
|
|
@ -89,9 +101,9 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||
public function anonymize(): void
|
||||
{
|
||||
$this->update([
|
||||
'name' => 'Gelöschter Benutzer #' . $this->id,
|
||||
'name' => 'Gelöschter Benutzer #'.$this->id,
|
||||
'display_name' => null,
|
||||
'email' => 'deleted_' . $this->id . '@anonymized.local',
|
||||
'email' => 'deleted_'.$this->id.'@anonymized.local',
|
||||
'password' => bcrypt(Str::random(64)),
|
||||
]);
|
||||
|
||||
|
|
@ -118,7 +130,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||
* Send the password reset notification.
|
||||
*
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function sendPasswordResetNotification($token): void
|
||||
{
|
||||
|
|
@ -127,8 +138,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||
|
||||
/**
|
||||
* Send the email verification notification.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function sendEmailVerificationNotification(): void
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue