2015-07-05 16:39:25 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FireflyIII\Helpers\Csv\Converter;
|
|
|
|
|
|
|
|
use Auth;
|
|
|
|
use FireflyIII\Models\Account;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class OpposingName
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Helpers\Csv\Converter
|
|
|
|
*/
|
|
|
|
class OpposingAccountName extends BasicConverter implements ConverterInterface
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If mapped, return account. Otherwise, only return the name itself.
|
|
|
|
*
|
|
|
|
* @return Account|string
|
|
|
|
*/
|
|
|
|
public function convert()
|
|
|
|
{
|
|
|
|
if (isset($this->mapped[$this->index][$this->value])) {
|
|
|
|
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
|
|
|
|
|
|
|
|
return $account;
|
|
|
|
} else {
|
|
|
|
return $this->value;
|
|
|
|
}
|
|
|
|
}
|
2015-07-09 21:26:40 +02:00
|
|
|
}
|