pai-sklep/app/Models/Order.php

29 lines
640 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(Address::class, "addressId", "id");
}
public function user()
{
return $this->belongsTo(User::class, "userId", "uuid");
}
public function products()
{
return $this->belongsToMany(Product::class, "orderProduct", "orderId" ,"productId")->withPivot("quantity");
}
}