cineflex/app/Models/Order.php

47 lines
960 B
PHP
Raw Normal View History

2022-11-23 09:32:34 +01:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Order extends Model
{
// An order has many tickets, can have two addresses, and belongs to a user
protected $table = 'orders';
protected $primaryKey = 'order_id';
protected $fillable = [
'user_id',
'order_number',
'order_status',
'billing_address_id',
];
protected $hidden = [
'created_at',
'updated_at',
];
public function user()
{
return $this->belongsTo(User::class, 'user_id', 'user_id');
}
public function billingAddress()
{
return $this->belongsTo(Address::class, 'billing_address_id', 'address_id');
}
public function shippingAddress()
{
return $this->belongsTo(Address::class, 'shipping_address_id', 'address_id');
}
public function tickets()
{
return $this->hasMany(Ticket::class, 'order_id', 'order_id');
}
}