Skip to content

Firefly III: a personal finances manager

Move some stuff around.

James Cole5b949d6e00cf
diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php
index e96d36e1e1..31f9d2639d 100644
--- a/app/Http/Controllers/TransactionController.php
+++ b/app/Http/Controllers/TransactionController.php
@@ -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!');
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php
index f779600bc9..400c68dbb5 100644
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@ -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;
diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php
index 7455e9f744..1aa35b62d9 100644
--- a/app/Repositories/Bill/BillRepository.php
+++ b/app/Repositories/Bill/BillRepository.php
@@ -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.
/*
diff --git a/app/Models/BaseModel.php b/app/Support/Models/TransactionJournalSupport.php
similarity index 52%
rename from app/Models/BaseModel.php
rename to app/Support/Models/TransactionJournalSupport.php
index a209a5183c..178d7a192c 100644
--- a/app/Models/BaseModel.php
+++ b/app/Support/Models/TransactionJournalSupport.php
@@ -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;
}
+
}
\ No newline at end of file