2021-09-05 02:22:17 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
|
|
use Illuminate\Notifications\Notifiable;
|
|
|
|
use Laravel\Sanctum\HasApiTokens;
|
|
|
|
|
2021-11-14 14:51:49 +01:00
|
|
|
class User extends Authenticatable
|
|
|
|
{
|
|
|
|
use HasApiTokens;
|
|
|
|
use HasFactory;
|
|
|
|
use HasUUID;
|
|
|
|
use Notifiable;
|
2021-10-28 11:19:27 +02:00
|
|
|
|
|
|
|
public $primaryKey = "uuid";
|
2021-09-05 02:22:17 +02:00
|
|
|
/**
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
*
|
|
|
|
* @var string[]
|
|
|
|
*/
|
|
|
|
protected $fillable = [
|
|
|
|
'name',
|
|
|
|
'email',
|
|
|
|
'password',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that should be hidden for serialization.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $hidden = [
|
|
|
|
'password',
|
|
|
|
'remember_token',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that should be cast.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $casts = [
|
|
|
|
'email_verified_at' => 'datetime',
|
|
|
|
];
|
2021-11-19 08:04:04 +01:00
|
|
|
|
2021-11-24 11:34:46 +01:00
|
|
|
public function isAdmin()
|
|
|
|
{
|
|
|
|
return $this->admin;
|
2021-11-20 22:12:35 +01:00
|
|
|
}
|
|
|
|
|
2021-11-24 11:34:46 +01:00
|
|
|
public function cart()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany(Product::class, "cart_items", "userID", "productID");
|
2021-11-19 08:04:04 +01:00
|
|
|
}
|
2021-12-07 12:22:46 +01:00
|
|
|
|
|
|
|
public function orders()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Order::class, "userID");
|
|
|
|
}
|
2021-09-05 02:22:17 +02:00
|
|
|
}
|