/**
  * @param $value
  *
  * @return mixed
  */
 public static function routeBinder($value)
 {
     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')->where('budgets.user_id', auth()->user()->id)->first(['limit_repetitions.*']);
         if ($object) {
             return $object;
         }
     }
     throw new NotFoundHttpException();
 }
Exemple #2
0
        }
    }
    throw new NotFoundHttpException();
});
Route::bind('budget', function ($value) {
    if (Auth::check()) {
        $object = Budget::where('id', $value)->where('user_id', Auth::user()->id)->first();
        if ($object) {
            return $object;
        }
    }
    throw new NotFoundHttpException();
});
Route::bind('limitrepetition', function ($value) {
    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')->where('budgets.user_id', Auth::user()->id)->first(['limit_repetitions.*']);
        if ($object) {
            return $object;
        }
    }
    throw new NotFoundHttpException();
});
Route::bind('piggyBank', function ($value) {
    if (Auth::check()) {
        $object = PiggyBank::where('piggy_banks.id', $value)->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', Auth::user()->id)->first(['piggy_banks.*']);
        if ($object) {
            return $object;
        }
    }
    throw new NotFoundHttpException();
});