add tooltip to sidebar buttons remove profile for admin fix mobile menu not opening in home page fix deal image input modal size in mobile view make image scrollable in input modal fix explore page filters are not clickable when recent search is maxed out change UI for the recent searches add seeder for categories improve deal card ui in broker dashboard
156 lines
5.3 KiB
PHP
156 lines
5.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property string $name
|
|
* @property string $email
|
|
* @property \Illuminate\Support\Carbon|null $email_verified_at
|
|
* @property string $password
|
|
* @property string|null $remember_token
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
* @property string $status
|
|
* @property string $role
|
|
* @property string|null $role_type
|
|
* @property int|null $role_id
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Deal> $deals
|
|
* @property-read int|null $deals_count
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Interaction> $dealsInteractions
|
|
* @property-read int|null $deals_interactions_count
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Deal> $interactedDeals
|
|
* @property-read int|null $interacted_deals_count
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, User> $interactions
|
|
* @property-read int|null $interactions_count
|
|
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection<int, \Illuminate\Notifications\DatabaseNotification> $notifications
|
|
* @property-read int|null $notifications_count
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\RecentSearch> $recentSearches
|
|
* @property-read int|null $recent_searches_count
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Report> $reports
|
|
* @property-read int|null $reports_count
|
|
* @property-read Model|\Eloquent|null $type
|
|
*
|
|
* @method static \Database\Factories\UserFactory factory($count = null, $state = [])
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User whereEmail($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User whereEmailVerifiedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User whereName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User wherePassword($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User whereRememberToken($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User whereRole($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User whereRoleId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User whereRoleType($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User whereStatus($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User whereUpdatedAt($value)
|
|
*
|
|
* @mixin \Eloquent
|
|
*/
|
|
class User extends Authenticatable
|
|
{
|
|
/** @use HasFactory<\Database\Factories\UserFactory> */
|
|
use HasFactory, Notifiable;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'email',
|
|
'password',
|
|
'status',
|
|
'role',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be hidden for serialization.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'email_verified_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
];
|
|
}
|
|
|
|
public function isBroker(): bool
|
|
{
|
|
return $this->type instanceof Broker;
|
|
}
|
|
|
|
public function isAdmin(): bool
|
|
{
|
|
return $this->type instanceof Admin;
|
|
}
|
|
|
|
public function isCustomer(): bool
|
|
{
|
|
return $this->type instanceof Customer;
|
|
}
|
|
|
|
public function deals(): HasMany
|
|
{
|
|
return $this->hasMany(Deal::class);
|
|
}
|
|
|
|
/**
|
|
* Returns model of User's role type
|
|
*/
|
|
public function type(): MorphTo
|
|
{
|
|
return $this->morphTo('role');
|
|
}
|
|
|
|
public function interactions(): HasMany
|
|
{
|
|
return $this->hasMany(User::class);
|
|
}
|
|
|
|
public function recentSearches(): HasMany
|
|
{
|
|
return $this->hasMany(RecentSearch::class);
|
|
}
|
|
|
|
public function dealsInteractions(): HasManyThrough
|
|
{
|
|
return $this->hasManyThrough(Interaction::class, Deal::class);
|
|
}
|
|
|
|
public function interactedDeals(): HasManyThrough
|
|
{
|
|
return $this->hasManyThrough(Deal::class, Interaction::class, 'user_id', 'id', 'id', 'deal_id');
|
|
}
|
|
|
|
public function reports(): HasMany
|
|
{
|
|
return $this->hasMany(Report::class);
|
|
}
|
|
}
|