pai-sklep/app/Models/Order.php
2021-11-14 14:51:49 +01:00

28 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");
}
}