Files
firefly-iii/app/Http/Controllers/Transaction/SingleController.php

91 lines
3.0 KiB
PHP
Raw Normal View History

2016-10-21 19:20:03 +02:00
<?php
/**
* SingleController.php
2017-10-21 08:40:00 +02:00
* Copyright (c) 2017 thegrumpydictator@gmail.com
2016-10-21 19:20:03 +02:00
*
2017-10-21 08:40:00 +02:00
* This file is part of Firefly III.
2016-10-21 19:20:03 +02:00
*
2017-10-21 08:40:00 +02:00
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2017-12-17 14:44:05 +01:00
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
2016-10-21 19:20:03 +02:00
*/
declare(strict_types=1);
2016-10-21 19:20:03 +02:00
namespace FireflyIII\Http\Controllers\Transaction;
2017-08-21 17:11:18 +02:00
use Carbon\Carbon;
2019-03-30 11:03:39 +01:00
use FireflyIII\Events\StoredTransactionGroup;
use FireflyIII\Events\UpdatedTransactionGroup;
use FireflyIII\Exceptions\FireflyException;
2016-10-21 19:20:03 +02:00
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\JournalFormRequest;
2017-07-07 17:51:14 +02:00
use FireflyIII\Models\Transaction;
2016-10-21 19:20:03 +02:00
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionJournalMeta;
2016-10-21 19:20:03 +02:00
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
2018-08-09 16:13:13 +02:00
use FireflyIII\Support\Http\Controllers\ModelInformation;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
2017-11-24 17:33:05 +01:00
use Illuminate\Http\Request;
2016-10-21 19:20:03 +02:00
use Log;
use View;
/**
2017-11-15 12:25:49 +01:00
* Class SingleController.
2018-07-20 14:34:56 +02:00
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2016-10-21 19:20:03 +02:00
*/
class SingleController extends Controller
{
2019-04-19 07:00:19 +02:00
2018-08-09 16:13:13 +02:00
use ModelInformation;
2018-07-22 08:10:16 +02:00
/** @var AttachmentHelperInterface The attachment helper. */
2016-10-21 19:20:03 +02:00
private $attachments;
2018-07-21 08:06:24 +02:00
/** @var BudgetRepositoryInterface The budget repository */
2016-10-21 19:20:03 +02:00
private $budgets;
/** @var JournalRepositoryInterface Journals and transactions overview */
2017-07-04 16:31:16 +02:00
private $repository;
2016-10-21 19:20:03 +02:00
/**
2018-07-22 08:10:16 +02:00
* SingleController constructor.
2016-10-21 19:20:03 +02:00
*/
public function __construct()
{
2019-04-19 07:00:19 +02:00
throw new FireflyException('Do not use me.');
2016-10-21 19:20:03 +02:00
parent::__construct();
2017-11-25 20:54:42 +01:00
$maxFileSize = app('steam')->phpBytes(ini_get('upload_max_filesize'));
$maxPostSize = app('steam')->phpBytes(ini_get('post_max_size'));
2016-10-21 19:20:03 +02:00
$uploadSize = min($maxFileSize, $maxPostSize);
app('view')->share('uploadSize', $uploadSize);
2016-10-21 19:20:03 +02:00
// some useful repositories:
$this->middleware(
function ($request, $next) {
$this->budgets = app(BudgetRepositoryInterface::class);
$this->attachments = app(AttachmentHelperInterface::class);
2017-07-04 16:31:16 +02:00
$this->repository = app(JournalRepositoryInterface::class);
2016-10-21 19:20:03 +02:00
2018-07-15 09:38:49 +02:00
app('view')->share('title', (string)trans('firefly.transactions'));
2017-12-16 19:46:36 +01:00
app('view')->share('mainTitleIcon', 'fa-repeat');
2016-10-29 07:44:46 +02:00
2016-10-21 19:20:03 +02:00
return $next($request);
}
);
}
2016-10-23 12:42:44 +02:00
}