More code for import routine.

This commit is contained in:
James Cole
2018-05-07 20:35:14 +02:00
parent 626f7357bb
commit 7f4feb0cfc
8 changed files with 380 additions and 50 deletions

View File

@@ -243,6 +243,18 @@ class BillRepository implements BillRepositoryInterface
return $sum;
}
/**
* Get all bills with these ID's.
*
* @param array $billIds
*
* @return Collection
*/
public function getByIds(array $billIds): Collection
{
return $this->user->bills()->whereIn('id', $billIds)->get();
}
/**
* Get text or return empty string.
*
@@ -393,11 +405,11 @@ class BillRepository implements BillRepositoryInterface
$rules = $this->user->rules()
->leftJoin('rule_actions', 'rule_actions.rule_id', '=', 'rules.id')
->where('rule_actions.action_type', 'link_to_bill')
->get(['rules.id', 'rules.title', 'rule_actions.action_value','rules.active']);
->get(['rules.id', 'rules.title', 'rule_actions.action_value', 'rules.active']);
$array = [];
foreach ($rules as $rule) {
$array[$rule->action_value] = $array[$rule->action_value] ?? [];
$array[$rule->action_value][] = ['id' => $rule->id, 'title' => $rule->title,'active' => $rule->active];
$array[$rule->action_value][] = ['id' => $rule->id, 'title' => $rule->title, 'active' => $rule->active];
}
$return = [];
foreach ($collection as $bill) {

View File

@@ -98,6 +98,15 @@ interface BillRepositoryInterface
*/
public function getBillsUnpaidInRange(Carbon $start, Carbon $end): string;
/**
* Get all bills with these ID's.
*
* @param array $billIds
*
* @return Collection
*/
public function getByIds(array $billIds): Collection;
/**
* Get text or return empty string.
*