. */ declare(strict_types=1); namespace FireflyIII\Support\Binder; use FireflyIII\Models\CurrencyExchangeRate; use FireflyIII\User; use Illuminate\Routing\Route; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class UserGroupTransaction. */ class UserGroupExchangeRate implements BinderInterface { public static function routeBinder(string $value, Route $route): CurrencyExchangeRate { if (auth()->check()) { /** @var User $user */ $user = auth()->user(); $rate = CurrencyExchangeRate::where('id', (int) $value) ->where('user_group_id', $user->user_group_id) ->first() ; if (null !== $rate) { return $rate; } } throw new NotFoundHttpException(); } }