/** * Find by ID * * @param int $currencyId * * @return TransactionCurrency */ public function find(int $currencyId) : TransactionCurrency { $currency = TransactionCurrency::find($currencyId); if (is_null($currency)) { $currency = new TransactionCurrency(); } return $currency; }
/** * @return TransactionCurrency */ public function convert() { if (isset($this->mapped[$this->index][$this->value])) { $currency = TransactionCurrency::find($this->mapped[$this->index][$this->value]); } else { $currency = TransactionCurrency::whereCode($this->value)->first(); } return $currency; }
} } throw new NotFoundHttpException(); }); Route::bind('attachment', function ($value) { if (Auth::check()) { $object = Attachment::where('id', $value)->where('user_id', Auth::user()->id)->first(); if ($object) { return $object; } } throw new NotFoundHttpException(); }); Route::bind('currency', function ($value) { if (Auth::check()) { $object = TransactionCurrency::find($value); if ($object) { return $object; } } throw new NotFoundHttpException(); }); Route::bind('bill', function ($value) { if (Auth::check()) { $object = Bill::where('id', $value)->where('user_id', Auth::user()->id)->first(); if ($object) { return $object; } } throw new NotFoundHttpException(); });