mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
More bindings.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
<?php namespace FireflyIII\Models;
|
||||
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* FireflyIII\Models\LimitRepetition
|
||||
@@ -44,4 +46,20 @@ class LimitRepetition extends Model
|
||||
$this->attributes['amount'] = strval(round($value, 2));
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user