MIF_E31221305/TA_website/app/Models/User.php

90 lines
1.9 KiB
PHP

<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasApiTokens, HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'email',
'password',
'phone',
'address',
'role',
'last_login_at',
'phone_number',
'latitude',
'longitude',
'shop_description',
'profile_photo',
];
/**
* 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',
'last_login_at' => 'datetime',
'latitude' => 'decimal:7',
'longitude' => 'decimal:7',
];
}
/**
* Get the orders for the user.
*/
public function orders()
{
return $this->hasMany(Booking::class, 'customer_id');
}
public function bookings()
{
return $this->hasMany(Booking::class, 'tailor_id');
}
public function galleries()
{
return $this->hasMany(TailorGallery::class);
}
public function reviews()
{
return $this->hasMany(TailorRating::class, 'tailor_id');
}
public function specializations()
{
return $this->belongsToMany(TailorSpecialization::class);
}
}