Example #1
0
 /**
  * Render a ModelNotFound exception into an HTTP response.
  *
  * @param  Illuminate\Database\Eloquent\ModelNotFoundException  $exception
  * @return \Illuminate\Http\RedirectResponse
  */
 public function renderModelnotFound(ModelNotFoundException $exception)
 {
     // Redirect when Account model not found
     if ($exception->getModel() === 'App\\Account') {
         return redirect()->action('HomeController@getIndex')->withErrors(trans('account.index.notfoundMessage'));
     }
     // Redirect when Envelope model not found
     if ($exception->getModel() === 'App\\Envelope') {
         return redirect()->action('HomeController@getIndex')->withErrors(trans('envelope.index.notfoundMessage'));
     }
     // Redirect when other model not found
     return redirect()->action('HomeController@getIndex')->withErrors([trans('app.error.404')]);
 }
Example #2
0
 /**
  * @param ModelNotFoundException $e
  *
  * @return Response
  */
 private function sendResponseForModelNotFound(ModelNotFoundException $e)
 {
     $model = $e->getModel();
     if (method_exists($model, 'getNotFoundMessage')) {
         $message = app()->call("{$model}@getNotFoundMessage");
     } else {
         $message = trans('cms::core.messages.model_not_found');
     }
     return back()->withErrors($message, 'model_not_found');
 }
Example #3
0
 /**
  * Get the model name, without the namespace.
  *
  * @param  \Illuminate\Database\Eloquent\ModelNotFoundException $error
  * @return string
  */
 protected function getModelName(ModelNotFoundException $error)
 {
     return $this->resources->name($error->getModel());
 }