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

39 lines
923 B
PHP
Raw Normal View History

2015-07-05 14:37:36 +02:00
<?php
namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use FireflyIII\Models\Account;
2015-07-09 16:03:47 +02:00
use Log;
2015-07-05 14:37:36 +02: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 16:03:47 +02:00
/** @var Account $account */
2015-07-05 14:37:36 +02:00
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
} else {
2015-07-09 16:03:47 +02:00
/** @var Account $account */
2015-07-05 14:37:36 +02:00
$account = Auth::user()->accounts()->find($this->value);
2015-07-09 16:03:47 +02:00
if (!is_null($account)) {
2015-07-15 21:06:26 +02:00
Log::debug('Found ' . $account->accountType->type . ' named "******" with ID: ' . $this->value . ' (not mapped) ');
2015-07-09 16:03:47 +02:00
}
2015-07-05 14:37:36 +02:00
}
return $account;
}
2015-07-09 21:26:40 +02:00
}