This commit is contained in:
Mathieu Lagace
2019-09-08 16:43:34 -04:00
parent 0bd86285ca
commit 133f430445
39 changed files with 789 additions and 74 deletions

View File

@@ -4,6 +4,7 @@ namespace App;
use Illuminate\Database\Eloquent\Model;
use mysql_xdevapi\Collection;
use function foo\func;
class Item extends Model
{
@@ -44,10 +45,12 @@ class Item extends Model
return \App\ItemCategory::find($this->category_id);
}
public function available()
public function available($begin = null,$end = null)
{
return $this->quantity - $this->booked();
if ($begin == null && $end == null)
{
return $this->quantity - $this->booked();
}
}
public function booked()
@@ -61,4 +64,15 @@ class Item extends Model
return $nbBooked;
}
public static function training()
{
$training = collect();
$training = \App\Item::all()->filter(function($value,$key){
return $value->category()->is_training == 1 && $value->category()->is_op_appro != 1;
});
return $training;
}
}