Skip to content

Commit

Permalink
Grouping MiningLeder by day
Browse files Browse the repository at this point in the history
  • Loading branch information
Fundaris authored Nov 1, 2018
1 parent 817483c commit 6968449
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Repositories/Character/MiningLedger.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

namespace Seat\Services\Repositories\Character;

use Illuminate\Support\Facades\DB;
use Seat\Eveapi\Models\Industry\CharacterMining;

/**
Expand All @@ -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;

Expand Down

0 comments on commit 6968449

Please sign in to comment.