mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-13 16:00:13 +00:00
Move some stuff around.
This commit is contained in:
@@ -144,6 +144,7 @@ class TransactionController extends Controller
|
||||
// get journal again:
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = TransactionJournal::expanded()->where('transaction_journals.id', $journal->id)->first(TransactionJournal::QUERYFIELDS);
|
||||
// TODO REMOVE this in favour of something static in TransactionJournal.
|
||||
// cannot edit opening balance
|
||||
if ($journal->isOpeningBalance()) {
|
||||
throw new FireflyException('Cannot edit this transaction (#' . $journal->id . '). Edit the account instead!');
|
||||
|
@@ -3,6 +3,7 @@
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Crypt;
|
||||
use FireflyIII\Support\Models\TransactionJournalSupport;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@@ -58,7 +59,7 @@ use Watson\Validating\ValidatingTrait;
|
||||
|
||||
*
|
||||
*/
|
||||
class TransactionJournal extends BaseModel
|
||||
class TransactionJournal extends TransactionJournalSupport
|
||||
{
|
||||
use SoftDeletes, ValidatingTrait;
|
||||
|
||||
|
@@ -447,6 +447,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
// looks weird, but is useful:
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = TransactionJournal::expanded()->where('transaction_journals.id', $journal->id)->get(TransactionJournal::QUERYFIELDS)->first();
|
||||
// TODO REMOVE this in favour of something static in TransactionJournal.
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -1,39 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* BaseModel.php
|
||||
* TransactionJournalSupport.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
namespace FireflyIII\Support\Models;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class BaseModel
|
||||
* Class TransactionJournalSupport
|
||||
*
|
||||
* @package FireflyIII\Models
|
||||
* @package FireflyIII\Support\Models
|
||||
*/
|
||||
class BaseModel extends Model
|
||||
class TransactionJournalSupport extends Model
|
||||
{
|
||||
/**
|
||||
* @param $query
|
||||
* @param $table
|
||||
* @param Builder $query
|
||||
* @param string $table
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isJoined($query, $table)
|
||||
public static function isJoined(Builder $query, string $table):bool
|
||||
{
|
||||
$joins = $query->getQuery()->joins;
|
||||
if($joins == null) {
|
||||
if (is_null($joins)) {
|
||||
return false;
|
||||
}
|
||||
foreach ($joins as $join) {
|
||||
if ($join->table == $table) {
|
||||
if ($join->table === $table) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user