Code clean up [skip ci]

This commit is contained in:
James Cole
2016-09-16 12:07:45 +02:00
parent a07799cfa4
commit f38984398d
60 changed files with 111 additions and 152 deletions

View File

@@ -153,7 +153,7 @@ class Account extends Model
public static function routeBinder(Account $value)
{
if (Auth::check()) {
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
return $value;
}

View File

@@ -69,7 +69,7 @@ class Attachment extends Model
*/
public static function routeBinder(Attachment $value)
{
if (Auth::check()) {
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
return $value;

View File

@@ -81,7 +81,7 @@ class Bill extends Model
*/
public static function routeBinder(Bill $value)
{
if (Auth::check()) {
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
return $value;
}

View File

@@ -94,7 +94,7 @@ class Budget extends Model
*/
public static function routeBinder(Budget $value)
{
if (Auth::check()) {
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
return $value;
}

View File

@@ -89,7 +89,7 @@ class Category extends Model
*/
public static function routeBinder(Category $value)
{
if (Auth::check()) {
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
return $value;
}

View File

@@ -44,7 +44,7 @@ class ExportJob extends Model
*/
public static function routeBinder($value)
{
if (Auth::check()) {
if (auth()->check()) {
$model = self::where('key', $value)->where('user_id', Auth::user()->id)->first();
if (!is_null($model)) {
return $model;

View File

@@ -62,7 +62,7 @@ class ImportJob extends Model
*/
public static function routeBinder($value)
{
if (Auth::check()) {
if (auth()->check()) {
$model = self::where('key', $value)->where('user_id', Auth::user()->id)->first();
if (!is_null($model)) {
return $model;

View File

@@ -54,7 +54,7 @@ class LimitRepetition extends Model
*/
public static function routeBinder($value)
{
if (Auth::check()) {
if (auth()->check()) {
$object = LimitRepetition::where('limit_repetitions.id', $value)
->leftJoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id')
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')

View File

@@ -70,7 +70,7 @@ class PiggyBank extends Model
*/
public static function routeBinder(PiggyBank $value)
{
if (Auth::check()) {
if (auth()->check()) {
if ($value->account->user_id == Auth::user()->id) {
return $value;
}

View File

@@ -59,7 +59,7 @@ class Rule extends Model
*/
public static function routeBinder(Rule $value)
{
if (Auth::check()) {
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
return $value;
}

View File

@@ -55,7 +55,7 @@ class RuleGroup extends Model
*/
public static function routeBinder(RuleGroup $value)
{
if (Auth::check()) {
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
return $value;
}

View File

@@ -96,7 +96,7 @@ class Tag extends TagSupport
*/
public static function routeBinder(Tag $value)
{
if (Auth::check()) {
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
return $value;
}

View File

@@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Models;
use Auth;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -53,7 +52,7 @@ class TransactionCurrency extends Model
*/
public static function routeBinder(TransactionCurrency $currency)
{
if (Auth::check()) {
if (auth()->check()) {
return $currency;
}
throw new NotFoundHttpException;

View File

@@ -128,7 +128,7 @@ class TransactionJournal extends TransactionJournalSupport
*/
public static function routeBinder($value)
{
if (Auth::check()) {
if (auth()->check()) {
$validTypes = [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER];
$object = TransactionJournal::where('transaction_journals.id', $value)
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
@@ -380,7 +380,8 @@ class TransactionJournal extends TransactionJournalSupport
'transaction_journals.completed',
'transaction_types.type',
'transaction_currencies.code',
]);
]
);
$query->with(['categories', 'budgets', 'attachments', 'bill', 'transactions']);
}