From 69684496ee3f4d16789c5915f7b704932220a7ba Mon Sep 17 00:00:00 2001 From: Fundaris <3646843+Fundaris@users.noreply.github.com> Date: Thu, 1 Nov 2018 22:58:03 +0100 Subject: [PATCH] Grouping MiningLeder by day --- src/Repositories/Character/MiningLedger.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Repositories/Character/MiningLedger.php b/src/Repositories/Character/MiningLedger.php index 48a9ac38..f66dc538 100644 --- a/src/Repositories/Character/MiningLedger.php +++ b/src/Repositories/Character/MiningLedger.php @@ -22,6 +22,7 @@ namespace Seat\Services\Repositories\Character; +use Illuminate\Support\Facades\DB; use Seat\Eveapi\Models\Industry\CharacterMining; /** @@ -40,14 +41,14 @@ trait MiningLedger public function getCharacterLedger(int $character_id, bool $get = true) { - $ledger = CharacterMining::select('character_minings.date', 'solar_system_id', 'character_minings.type_id') + $ledger = CharacterMining::select('character_minings.date', 'solar_system_id', 'character_minings.type_id', DB::raw('SUM(quantity) as quantity')) ->join('invTypes', 'invTypes.typeID', 'character_minings.type_id') ->leftJoin('historical_prices', function ($join) { $join->on('historical_prices.type_id', '=', 'character_minings.type_id') ->on('historical_prices.date', '=', 'character_minings.date'); }) - ->where('character_id', $character_id); - + ->where('character_id', $character_id) + ->groupBy('character_minings.date', 'solar_system_id', 'character_minings.type_id'); if (! $get) return $ledger;