Files
firefly-iii/app/Helpers/Csv/Mapper/AssetAccount.php

46 lines
1.0 KiB
PHP
Raw Normal View History

2015-07-05 06:18:02 +02:00
<?php
namespace FireflyIII\Helpers\Csv\Mapper;
2015-07-05 06:18:02 +02:00
use Auth;
use FireflyIII\Models\Account;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* Class AssetAccount
2015-07-05 06:18:02 +02:00
*
* @package FireflyIII\Helpers\Csv\Mapper
2015-07-05 06:18:02 +02:00
*/
class AssetAccount implements MapperInterface
2015-07-05 06:18:02 +02:00
{
/**
* @return array
*/
public function getMap()
2015-07-05 06:18:02 +02:00
{
$result = Auth::user()->accounts()->with(
['accountmeta' => function (HasMany $query) {
$query->where('name', 'accountRole');
}]
)->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
$list = [];
2015-07-06 08:14:19 +02:00
2015-07-05 06:18:02 +02:00
/** @var Account $account */
foreach ($result as $account) {
2015-07-06 08:14:19 +02:00
$name = $account->name;
if (strlen($account->iban) > 0) {
$name .= ' (' . $account->iban . ')';
}
$list[$account->id] = $name;
2015-07-05 06:18:02 +02:00
}
2015-07-05 18:18:44 +02:00
asort($list);
2015-07-09 19:36:14 +02:00
$list = [0 => trans('firefly.csv_do_not_map')] + $list;
2015-07-06 08:14:19 +02:00
2015-07-05 06:18:02 +02:00
return $list;
}
2015-07-09 21:26:40 +02:00
}