mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 10:53:37 +00:00
Code clean up.
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
@@ -43,13 +42,10 @@ use Steam;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class CategoryController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class CategoryController.
|
||||
*/
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -57,7 +53,6 @@ class CategoryController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', trans('firefly.categories'));
|
||||
@@ -75,7 +70,7 @@ class CategoryController extends Controller
|
||||
*/
|
||||
public function create(Request $request)
|
||||
{
|
||||
if (session('categories.create.fromStore') !== true) {
|
||||
if (true !== session('categories.create.fromStore')) {
|
||||
$this->rememberPreviousUri('categories.create.uri');
|
||||
}
|
||||
$request->session()->forget('categories.create.fromStore');
|
||||
@@ -104,7 +99,6 @@ class CategoryController extends Controller
|
||||
return view('categories.delete', compact('category', 'subTitle'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
@@ -134,7 +128,7 @@ class CategoryController extends Controller
|
||||
$subTitle = trans('firefly.edit_category', ['name' => $category->name]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('categories.edit.fromUpdate') !== true) {
|
||||
if (true !== session('categories.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('categories.edit.uri');
|
||||
}
|
||||
$request->session()->forget('categories.edit.fromUpdate');
|
||||
@@ -180,7 +174,7 @@ class CategoryController extends Controller
|
||||
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
||||
|
||||
// prep for "all" view.
|
||||
if ($moment === 'all') {
|
||||
if ('all' === $moment) {
|
||||
$subTitle = trans('firefly.all_journals_without_category');
|
||||
$first = $repository->first();
|
||||
$start = $first->date ?? new Carbon;
|
||||
@@ -188,7 +182,7 @@ class CategoryController extends Controller
|
||||
}
|
||||
|
||||
// prep for "specific date" view.
|
||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||
if (strlen($moment) > 0 && 'all' !== $moment) {
|
||||
$start = new Carbon($moment);
|
||||
$end = Navigation::endOfPeriod($start, $range);
|
||||
$subTitle = trans(
|
||||
@@ -199,7 +193,7 @@ class CategoryController extends Controller
|
||||
}
|
||||
|
||||
// prep for current period
|
||||
if (strlen($moment) === 0) {
|
||||
if (0 === strlen($moment)) {
|
||||
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||
$periods = $this->getNoCategoryPeriodOverview();
|
||||
@@ -209,7 +203,6 @@ class CategoryController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutCategory()->withOpposingAccount()
|
||||
@@ -242,28 +235,28 @@ class CategoryController extends Controller
|
||||
$periods = new Collection;
|
||||
|
||||
// prep for "all" view.
|
||||
if ($moment === 'all') {
|
||||
if ('all' === $moment) {
|
||||
$subTitle = trans('firefly.all_journals_for_category', ['name' => $category->name]);
|
||||
$first = $repository->firstUseDate($category);
|
||||
/** @var Carbon $start */
|
||||
$start = is_null($first) ? new Carbon : $first;
|
||||
$start = null === $first ? new Carbon : $first;
|
||||
$end = new Carbon;
|
||||
}
|
||||
|
||||
// prep for "specific date" view.
|
||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||
if (strlen($moment) > 0 && 'all' !== $moment) {
|
||||
$start = new Carbon($moment);
|
||||
$end = Navigation::endOfPeriod($start, $range);
|
||||
$subTitle = trans(
|
||||
'firefly.journals_in_period_for_category',
|
||||
['name' => $category->name,
|
||||
'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
||||
'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat),]
|
||||
);
|
||||
$periods = $this->getPeriodOverview($category);
|
||||
}
|
||||
|
||||
// prep for current period
|
||||
if (strlen($moment) === 0) {
|
||||
if (0 === strlen($moment)) {
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
/** @var Carbon $end */
|
||||
@@ -272,7 +265,7 @@ class CategoryController extends Controller
|
||||
$subTitle = trans(
|
||||
'firefly.journals_in_period_for_category',
|
||||
['name' => $category->name, 'start' => $start->formatLocalized($this->monthAndDayFormat),
|
||||
'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
||||
'end' => $end->formatLocalized($this->monthAndDayFormat),]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -284,11 +277,9 @@ class CategoryController extends Controller
|
||||
$transactions = $collector->getPaginatedJournals();
|
||||
$transactions->setPath(route('categories.show', [$category->id]));
|
||||
|
||||
|
||||
return view('categories.show', compact('category', 'moment', 'transactions', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param CategoryFormRequest $request
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
@@ -303,7 +294,7 @@ class CategoryController extends Controller
|
||||
$request->session()->flash('success', strval(trans('firefly.stored_category', ['name' => $category->name])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('create_another')) === 1) {
|
||||
if (1 === intval($request->get('create_another'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$request->session()->put('categories.create.fromStore', true);
|
||||
|
||||
@@ -314,7 +305,6 @@ class CategoryController extends Controller
|
||||
return redirect(route('categories.index'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param CategoryFormRequest $request
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
@@ -330,7 +320,7 @@ class CategoryController extends Controller
|
||||
$request->session()->flash('success', strval(trans('firefly.updated_category', ['name' => $category->name])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$request->session()->put('categories.edit.fromUpdate', true);
|
||||
|
||||
@@ -432,7 +422,7 @@ class CategoryController extends Controller
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||
$first = $repository->firstUseDate($category);
|
||||
if (is_null($first)) {
|
||||
if (null === $first) {
|
||||
$first = new Carbon;
|
||||
}
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
@@ -479,7 +469,7 @@ class CategoryController extends Controller
|
||||
]
|
||||
);
|
||||
$end = Navigation::subtractPeriod($end, $range, 1);
|
||||
$count++;
|
||||
++$count;
|
||||
}
|
||||
$cache->store($entries);
|
||||
|
||||
|
Reference in New Issue
Block a user