Initial Commit; base feats
This commit is contained in:
commit
9732135e90
137 changed files with 13856 additions and 0 deletions
46
app/Models/Order.php
Normal file
46
app/Models/Order.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?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');
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue