2021-11-14 14:51:49 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Order extends Model
|
|
|
|
{
|
|
|
|
use HasFactory;
|
|
|
|
use HasUUID;
|
|
|
|
public $primaryKey = "uuid";
|
|
|
|
protected $fillable = ['products'];
|
|
|
|
public function address()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Addres::class, "id", "addressId");
|
|
|
|
}
|
|
|
|
|
|
|
|
public function user()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(User::class, "userId", "uuid");
|
|
|
|
}
|
|
|
|
|
|
|
|
public function products()
|
|
|
|
{
|
2021-11-24 11:34:46 +01:00
|
|
|
return $this->belongsToMany("App\Product", "orderProduct", "productId", "orderId");
|
2021-11-14 14:51:49 +01:00
|
|
|
}
|
|
|
|
}
|