added "members" for an event that help the admins to moderate. members must be invited via email.
This commit is contained in:
@@ -3,21 +3,22 @@
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Filament\Models\Contracts\HasName;
|
||||
use Filament\Models\Contracts\HasTenants as FilamentHasTenants;
|
||||
use Filament\Panel;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Filament\Models\Contracts\HasTenants as FilamentHasTenants;
|
||||
use Filament\Panel;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Filament\Models\Contracts\HasName;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Collection;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
class User extends Authenticatable implements MustVerifyEmail, HasName, FilamentUser, FilamentHasTenants
|
||||
class User extends Authenticatable implements FilamentHasTenants, FilamentUser, HasName, MustVerifyEmail
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
@@ -38,6 +39,7 @@ class User extends Authenticatable implements MustVerifyEmail, HasName, Filament
|
||||
'address',
|
||||
'phone',
|
||||
'role',
|
||||
'tenant_id',
|
||||
'pending_purchase',
|
||||
];
|
||||
|
||||
@@ -77,7 +79,7 @@ class User extends Authenticatable implements MustVerifyEmail, HasName, Filament
|
||||
if (isset($credentials['login'])) {
|
||||
$login = $credentials['login'];
|
||||
$query->where('email', $login)
|
||||
->orWhere('username', $login);
|
||||
->orWhere('username', $login);
|
||||
} else {
|
||||
foreach ($this->getAuthIdentifiers() as $key => $value) {
|
||||
$query->where($key, $value);
|
||||
@@ -93,15 +95,16 @@ class User extends Authenticatable implements MustVerifyEmail, HasName, Filament
|
||||
protected function fullName(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn () => trim(($this->first_name ?? '') . ' ' . ($this->last_name ?? '')) ?: $this->name,
|
||||
get: fn () => trim(($this->first_name ?? '').' '.($this->last_name ?? '')) ?: $this->name,
|
||||
);
|
||||
}
|
||||
|
||||
public function getFilamentName(): string
|
||||
{
|
||||
if ($this->first_name && $this->last_name) {
|
||||
return trim($this->first_name . ' ' . $this->last_name);
|
||||
return trim($this->first_name.' '.$this->last_name);
|
||||
}
|
||||
|
||||
return $this->username ?? $this->email ?? 'Unnamed User';
|
||||
}
|
||||
|
||||
@@ -138,7 +141,7 @@ class User extends Authenticatable implements MustVerifyEmail, HasName, Filament
|
||||
return (int) $tenant->getKey() === (int) $ownedTenant->getKey();
|
||||
}
|
||||
|
||||
public function getTenants(Panel $panel): array | Collection
|
||||
public function getTenants(Panel $panel): array|Collection
|
||||
{
|
||||
if ($this->role === 'super_admin') {
|
||||
return Tenant::query()->orderBy('name')->get();
|
||||
@@ -148,4 +151,9 @@ class User extends Authenticatable implements MustVerifyEmail, HasName, Filament
|
||||
|
||||
return $tenant ? collect([$tenant]) : collect();
|
||||
}
|
||||
|
||||
public function eventMemberships(): HasMany
|
||||
{
|
||||
return $this->hasMany(EventMember::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user