pai-sklep/app/Models/Order.php

29 lines
617 B
PHP
Raw Permalink Normal View History

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()
{
2021-12-07 12:22:46 +01:00
return $this->belongsTo(Address::class, "addressId", "id");
2021-11-14 14:51:49 +01:00
}
public function user()
{
return $this->belongsTo(User::class, "userId", "uuid");
}
public function products()
{
2021-12-07 12:22:46 +01:00
return $this->belongsToMany(Product::class, "orderProduct", "orderId" ,"productId");
2021-11-14 14:51:49 +01:00
}
}