firefly-iii/app/Helpers/Csv/Converter/BudgetId.php
2016-02-05 12:08:25 +01:00

31 lines
663 B
PHP

<?php
declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use FireflyIII\Models\Budget;
/**
* Class BudgetId
*
* @package FireflyIII\Helpers\Csv\Converter
*/
class BudgetId extends BasicConverter implements ConverterInterface
{
/**
* @return Budget
*/
public function convert()
{
// is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) {
$budget = Auth::user()->budgets()->find($this->mapped[$this->index][$this->value]);
} else {
$budget = Auth::user()->budgets()->find($this->value);
}
return $budget;
}
}