firefly-iii/app/Helpers/Csv/Converter/AccountId.php

39 lines
921 B
PHP
Raw Normal View History

2015-07-05 07:37:36 -05:00
<?php
namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use FireflyIII\Models\Account;
2015-07-09 09:03:47 -05:00
use Log;
2015-07-05 07:37:36 -05:00
/**
* Class AccountId
*
* @package FireflyIII\Helpers\Csv\Converter
*/
class AccountId extends BasicConverter implements ConverterInterface
{
/**
* @return Account
*/
public function convert()
{
// is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) {
2015-07-09 09:03:47 -05:00
/** @var Account $account */
2015-07-05 07:37:36 -05:00
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
} else {
2015-07-09 09:03:47 -05:00
/** @var Account $account */
2015-07-05 07:37:36 -05:00
$account = Auth::user()->accounts()->find($this->value);
2015-07-09 09:03:47 -05:00
if (!is_null($account)) {
Log::debug('Found ' . $account->accountType->type . ' named "******" with ID: ' . $this->value.' (not mapped) ');
2015-07-09 09:03:47 -05:00
}
2015-07-05 07:37:36 -05:00
}
return $account;
}
2015-07-09 14:26:40 -05:00
}