} | } | ||||
$distributionsByMonthArray = []; | $distributionsByMonthArray = []; | ||||
$distributionsArray = $distributionModule->findDistributionsActive(); | |||||
$distributionsArray = $distributionModule->findDistributionsWithOrders(); | |||||
foreach ($distributionsArray as $distribution) { | foreach ($distributionsArray as $distribution) { | ||||
$month = date('Y-m', strtotime($distribution->date)); | $month = date('Y-m', strtotime($distribution->date)); | ||||
if (!isset($distributionsByMonthArray[$month])) { | if (!isset($distributionsByMonthArray[$month])) { |
->find(); | ->find(); | ||||
} | } | ||||
public function findDistributionsWithOrders() | |||||
{ | |||||
return $this->createDefaultQuery() | |||||
->filterHasOrders() | |||||
->orderBy('date ASC') | |||||
->find(); | |||||
} | |||||
/** | /** | ||||
* Récupère les distributions futures. | * Récupère les distributions futures. | ||||
*/ | */ |
return $this; | return $this; | ||||
} | } | ||||
public function filterHasOrders(): self | |||||
{ | |||||
$this->innerJoinWith('order'); | |||||
return $this; | |||||
} | |||||
public function filterByDateBetterThanToday(): self | public function filterByDateBetterThanToday(): self | ||||
{ | { | ||||
$this->query | $this->query |