예제 #1
0
파일: Bullet.php 프로젝트: elconejito/bang
 public static function updateInventory()
 {
     foreach (Bullet::all() as $bullet) {
         $rounds_purchased = DB::table('inventories')->where('bullet_id', $bullet->id)->sum('rounds');
         $rounds_fired = DB::table('shoots')->where('bullet_id', $bullet->id)->sum('rounds');
         $bullet->inventory = $rounds_purchased - $rounds_fired;
         $bullet->save();
     }
 }