29 lines
614 B
PHP
29 lines
614 B
PHP
|
<?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()
|
||
|
{
|
||
|
return $this->belongsToMany("App\Product", "orderProduct","productId", "orderId");
|
||
|
}
|
||
|
}
|