firefly-iii/app/Http/Controllers/Report/AccountController.php

60 lines
1.6 KiB
PHP
Raw Normal View History

2016-10-08 09:24:07 -05:00
<?php
/**
* AccountController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
declare(strict_types = 1);
namespace FireflyIII\Http\Controllers\Report;
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Repositories\Account\AccountTaskerInterface;
use FireflyIII\Support\CacheProperties;
2016-10-08 09:24:07 -05:00
use Illuminate\Support\Collection;
/**
* Class AccountController
*
* @package FireflyIII\Http\Controllers\Report
*/
class AccountController extends Controller
{
/**
2016-12-06 01:59:08 -06:00
* @param Collection $accounts
2016-10-08 09:24:07 -05:00
* @param Carbon $start
* @param Carbon $end
*
2016-12-06 01:59:08 -06:00
* @return mixed|string
2016-10-08 09:24:07 -05:00
*/
2016-12-06 01:59:08 -06:00
public function general(Collection $accounts, Carbon $start, Carbon $end)
2016-10-08 09:24:07 -05:00
{
// chart properties for cache:
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('account-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
return $cache->get();
}
2016-12-06 01:59:08 -06:00
/** @var AccountTaskerInterface $accountTasker */
2016-10-08 09:24:07 -05:00
$accountTasker = app(AccountTaskerInterface::class);
2016-12-06 01:59:08 -06:00
$accountReport = $accountTasker->getAccountReport($accounts, $start, $end);
2016-10-08 09:24:07 -05:00
$result = view('reports.partials.accounts', compact('accountReport'))->render();
$cache->store($result);
2016-10-29 00:44:46 -05:00
return $result;
2016-10-08 09:24:07 -05:00
}
2016-10-23 05:42:44 -05:00
}