mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-09 07:33:06 -06:00
39 lines
852 B
PHP
39 lines
852 B
PHP
<?php
|
|
declare(strict_types = 1);
|
|
namespace FireflyIII\Helpers\Csv\Converter;
|
|
|
|
use Auth;
|
|
use FireflyIII\Models\Bill;
|
|
|
|
/**
|
|
* Class BillName
|
|
*
|
|
* @package FireflyIII\Helpers\Csv\Converter
|
|
*/
|
|
class BillName extends BasicConverter implements ConverterInterface
|
|
{
|
|
|
|
/**
|
|
* @return Bill
|
|
*/
|
|
public function convert()
|
|
{
|
|
$bill = null;
|
|
// is mapped? Then it's easy!
|
|
if (isset($this->mapped[$this->index][$this->value])) {
|
|
$bill = Auth::user()->bills()->find($this->mapped[$this->index][$this->value]);
|
|
} else {
|
|
|
|
$bills = Auth::user()->bills()->get();
|
|
/** @var Bill $bill */
|
|
foreach ($bills as $bill) {
|
|
if ($bill->name == $this->value) {
|
|
return $bill;
|
|
}
|
|
}
|
|
}
|
|
|
|
return $bill;
|
|
}
|
|
}
|