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