2016-03-02 12:52:36 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2016-03-02 19:41:22 +01:00
|
|
|
* TransactionJournalSupport.php
|
2016-03-02 12:52:36 +01:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2016-03-02 19:41:22 +01:00
|
|
|
namespace FireflyIII\Support\Models;
|
2016-03-02 12:52:36 +01:00
|
|
|
|
2016-03-02 19:41:22 +01:00
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
2016-03-02 12:52:36 +01:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2016-03-02 19:41:22 +01:00
|
|
|
|
2016-03-02 12:52:36 +01:00
|
|
|
/**
|
2016-03-02 19:41:22 +01:00
|
|
|
* Class TransactionJournalSupport
|
2016-03-02 12:52:36 +01:00
|
|
|
*
|
2016-03-02 19:41:22 +01:00
|
|
|
* @package FireflyIII\Support\Models
|
2016-03-02 12:52:36 +01:00
|
|
|
*/
|
2016-03-02 19:41:22 +01:00
|
|
|
class TransactionJournalSupport extends Model
|
2016-03-02 12:52:36 +01:00
|
|
|
{
|
|
|
|
/**
|
2016-03-02 19:41:22 +01:00
|
|
|
* @param Builder $query
|
|
|
|
* @param string $table
|
2016-03-02 12:52:36 +01:00
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2016-03-02 19:41:22 +01:00
|
|
|
public static function isJoined(Builder $query, string $table):bool
|
2016-03-02 12:52:36 +01:00
|
|
|
{
|
|
|
|
$joins = $query->getQuery()->joins;
|
2016-03-02 19:41:22 +01:00
|
|
|
if (is_null($joins)) {
|
2016-03-02 12:52:36 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
foreach ($joins as $join) {
|
2016-03-02 19:41:22 +01:00
|
|
|
if ($join->table === $table) {
|
2016-03-02 12:52:36 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2016-03-02 19:41:22 +01:00
|
|
|
|
2016-03-02 12:52:36 +01:00
|
|
|
return false;
|
|
|
|
}
|
2016-03-02 19:41:22 +01:00
|
|
|
|
2016-03-02 12:52:36 +01:00
|
|
|
}
|