mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-07 06:33:57 -06:00
563ede822f
Signed-off-by: James Cole <thegrumpydictator@gmail.com>
64 lines
1.1 KiB
PHP
64 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Bill.php
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
*
|
|
* This software may be modified and distributed under the terms
|
|
* of the MIT license. See the LICENSE file for details.
|
|
*/
|
|
|
|
declare(strict_types = 1);
|
|
namespace FireflyIII\Helpers\Collection;
|
|
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
/**
|
|
* Class Bill
|
|
*
|
|
* @package FireflyIII\Helpers\Collection
|
|
*/
|
|
class Bill
|
|
{
|
|
|
|
/**
|
|
* @var Collection
|
|
*/
|
|
protected $bills;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->bills = new Collection;
|
|
}
|
|
|
|
/**
|
|
* @param BillLine $bill
|
|
*/
|
|
public function addBill(BillLine $bill)
|
|
{
|
|
$this->bills->push($bill);
|
|
}
|
|
|
|
/**
|
|
* @return Collection
|
|
*/
|
|
public function getBills(): Collection
|
|
{
|
|
$set = $this->bills->sortBy(
|
|
function (BillLine $bill) {
|
|
$active = intval($bill->getBill()->active) == 0 ? 1 : 0;
|
|
$name = $bill->getBill()->name;
|
|
|
|
return $active . $name;
|
|
}
|
|
);
|
|
|
|
|
|
return $set;
|
|
}
|
|
|
|
}
|