Add ItemCategory form

This commit is contained in:
Mathieu Lagace
2019-08-28 12:57:51 -04:00
parent caf44ba58a
commit d01bf2fca7
12 changed files with 437 additions and 64 deletions

View File

@@ -31,4 +31,22 @@ class Item extends Model
{
return \App\ItemCategory::find($this->category_id);
}
public function available()
{
return $this->quantity - $this->booked();
}
public function booked()
{
$nbBooked = 0;
foreach ($this->bookings() as $b)
{
$nbBooked = $nbBooked + $b->amount;
}
return $nbBooked;
}
}