mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
129 - Total Revenue and a Relationship Bug
This commit is contained in:
@@ -48,7 +48,7 @@ class Concert extends Model
|
||||
|
||||
public function orders()
|
||||
{
|
||||
return $this->belongsToMany(Order::class, 'tickets');
|
||||
return Order::whereIn('id', $this->tickets()->pluck('order_id'));
|
||||
}
|
||||
|
||||
public function hasOrderFor($customerEmail)
|
||||
@@ -114,4 +114,9 @@ class Concert extends Model
|
||||
{
|
||||
return number_format(($this->ticketsSold() / $this->totalTickets()) * 100, 2);
|
||||
}
|
||||
|
||||
public function revenueInDollars()
|
||||
{
|
||||
return $this->orders()->sum('amount') / 100;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user