%PDF- %PDF-
Direktori : /mnt/tnb2/git/loslex/app/Models/ |
Current File : //mnt/tnb2/git/loslex/app/Models/User.php |
<?php namespace App\Models; use Illuminate\Support\Str; use App\Models\Registration; use Laravel\Sanctum\HasApiTokens; use Illuminate\Notifications\Notifiable; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Database\Eloquent\Relations\BelongsToMany; class User extends Authenticatable implements MustVerifyEmail { use HasApiTokens, HasFactory, Notifiable; /** * The attributes that are mass assignable. * * @var array<int, string> */ protected $fillable = [ 'firstname', 'lastname', 'username', 'namesuffix', 'city', 'email', 'password', 'licence_number', 'phone_number', 'lex_hash', 'last_login', 'ban_reason', 'is_active', ]; /** * The attributes that should be hidden for serialization. * * @var array<int, string> */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array<string, string> */ protected $casts = [ 'email_verified_at' => 'datetime', ]; // Concatenate First and Last name to display on the web public function displayname(): Attribute { return Attribute::make( get: fn (mixed $value, array $attr) => implode(" ", array_filter([$attr['firstname'], $attr['lastname'], $attr['namesuffix']])) ); } public function displayanonname(): Attribute { return Attribute::make( get: fn (mixed $value, array $attr) => implode(" ", array_filter([ Str::mask($attr['firstname'], '*', 1), Str::mask($attr['lastname'], '*', 1), Str::mask($attr['namesuffix'], '*', 1) ])) ); } public function organizer_groups(): BelongsToMany { return $this->belongsToMany(OrganizerGroup::class, 'organizer_group_users', 'user_id', 'organizer_group_id'); } public function registrations(): HasMany { return $this->hasMany(Registration::class); } }