mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Routes will throw 404's
This commit is contained in:
parent
be96a4fce5
commit
21644ff4dd
@ -6,9 +6,10 @@ use FireflyIII\Models\Category;
|
|||||||
use FireflyIII\Models\LimitRepetition;
|
use FireflyIII\Models\LimitRepetition;
|
||||||
use FireflyIII\Models\PiggyBank;
|
use FireflyIII\Models\PiggyBank;
|
||||||
use FireflyIII\Models\Reminder;
|
use FireflyIII\Models\Reminder;
|
||||||
|
use FireflyIII\Models\Tag;
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Models\Tag;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
|
|
||||||
// models
|
// models
|
||||||
@ -16,102 +17,125 @@ Route::bind(
|
|||||||
'account',
|
'account',
|
||||||
function ($value, $route) {
|
function ($value, $route) {
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
$account = Account::leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
$object = Account::leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||||
->where('account_types.editable', 1)
|
->where('account_types.editable', 1)
|
||||||
->where('accounts.id', $value)
|
->where('accounts.id', $value)
|
||||||
->where('user_id', Auth::user()->id)
|
->where('user_id', Auth::user()->id)
|
||||||
->first(['accounts.*']);
|
->first(['accounts.*']);
|
||||||
if ($account) {
|
if ($object) {
|
||||||
return $account;
|
return $object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
App::abort(404);
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Route::bind(
|
Route::bind(
|
||||||
'tjSecond', function ($value, $route) {
|
'tjSecond', function ($value, $route) {
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
return TransactionJournal::
|
$object = TransactionJournal::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||||
where('id', $value)->where('user_id', Auth::user()->id)->first();
|
if ($object) {
|
||||||
|
return $object;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Route::bind(
|
Route::bind(
|
||||||
'tj', function ($value, $route) {
|
'tj', function ($value, $route) {
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
return TransactionJournal::
|
$object = TransactionJournal::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||||
where('id', $value)->where('user_id', Auth::user()->id)->first();
|
if ($object) {
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Route::bind(
|
Route::bind(
|
||||||
'currency', function ($value, $route) {
|
'currency', function ($value, $route) {
|
||||||
return TransactionCurrency::find($value);
|
if (Auth::check()) {
|
||||||
|
$object = TransactionCurrency::find($value);
|
||||||
|
if ($object) {
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Route::bind(
|
Route::bind(
|
||||||
'bill', function ($value, $route) {
|
'bill', function ($value, $route) {
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
return Bill::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
$object = Bill::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||||
|
if ($object) {
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Route::bind(
|
Route::bind(
|
||||||
'budget', function ($value, $route) {
|
'budget', function ($value, $route) {
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
return Budget::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
$object = Budget::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||||
|
if ($object) {
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Route::bind(
|
Route::bind(
|
||||||
'reminder', function ($value, $route) {
|
'reminder', function ($value, $route) {
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
return Reminder::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
$object = Reminder::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||||
|
if ($object) {
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Route::bind(
|
Route::bind(
|
||||||
'limitrepetition', function ($value, $route) {
|
'limitrepetition', function ($value, $route) {
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
return LimitRepetition::where('limit_repetitions.id', $value)
|
$object = LimitRepetition::where('limit_repetitions.id', $value)
|
||||||
->leftjoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id')
|
->leftjoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id')
|
||||||
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
|
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
|
||||||
->where('budgets.user_id', Auth::user()->id)
|
->where('budgets.user_id', Auth::user()->id)
|
||||||
->first(['limit_repetitions.*']);
|
->first(['limit_repetitions.*']);
|
||||||
|
if ($object) {
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Route::bind(
|
Route::bind(
|
||||||
'piggyBank', function ($value, $route) {
|
'piggyBank', function ($value, $route) {
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
return PiggyBank::
|
$object = PiggyBank::where('piggy_banks.id', $value)
|
||||||
where('piggy_banks.id', $value)
|
|
||||||
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
|
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
|
||||||
->where('accounts.user_id', Auth::user()->id)
|
->where('accounts.user_id', Auth::user()->id)
|
||||||
->first(['piggy_banks.*']);
|
->first(['piggy_banks.*']);
|
||||||
|
if ($object) {
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -119,9 +143,12 @@ Route::bind(
|
|||||||
'category', function ($value, $route) {
|
'category', function ($value, $route) {
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
return Category::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
return Category::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||||
|
if ($object) {
|
||||||
|
$object = $object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -129,9 +156,12 @@ Route::bind(
|
|||||||
'tag', function ($value, $route) {
|
'tag', function ($value, $route) {
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
return Tag::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
return Tag::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||||
|
if ($object) {
|
||||||
|
$object = $object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user