2015-05-17 10:54:13 -05:00
|
|
|
<?php
|
2016-05-20 05:27:31 -05:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2016-02-05 05:08:25 -06:00
|
|
|
declare(strict_types = 1);
|
2015-05-17 10:54:13 -05:00
|
|
|
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
|
|
|
|
*/
|
2016-02-18 03:04:26 -06:00
|
|
|
public function getBills(): Collection
|
2015-05-17 10:54:13 -05:00
|
|
|
{
|
2015-06-16 23:11:35 -05:00
|
|
|
$set = $this->bills->sortBy(
|
2015-06-06 16:09:12 -05:00
|
|
|
function (BillLine $bill) {
|
2015-05-17 10:54:13 -05:00
|
|
|
$active = intval($bill->getBill()->active) == 0 ? 1 : 0;
|
2015-05-20 12:55:53 -05:00
|
|
|
$name = $bill->getBill()->name;
|
|
|
|
|
|
|
|
return $active . $name;
|
2015-05-17 10:54:13 -05:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2015-06-16 23:11:35 -05:00
|
|
|
return $set;
|
2015-05-17 10:54:13 -05:00
|
|
|
}
|
|
|
|
|
2015-05-20 12:56:14 -05:00
|
|
|
}
|