Mahdi.Pishguy:
in laravel5 my code as :
$data = Contents::whereSlug($content)->orWhere('id', '=', $content)->first();
maybe return null. i want to manage that with Custom Message and show that on view. for example:
Route::get('/showContent/{content}', function ($content) {
$data = Contents::whereSlug($content)->orWhere('id', '=', $content)->first();
if ($data == null) {
abort(404, 'content not found');
}
$serverInformation = ServerInformation::find(1);
return view('layouts.frontend.pages.showContent', compact(
'data',
'serverInformation'
));
});
i have errors
folder on resources/views/missing.blade.php
now i expect this message as content not found
show on view by this code:
unfortunately i get this error:
Undefined variable: exception (View: /Applications/XAMPP/xamppfiles/htdocs/alachiqServer/resources/views/errors/missing.blade.php
and render
on Handler.php
file:
public function render($request, Exception $e)
{
if ($e instanceof ModelNotFoundException or $e instanceof NotFoundHttpException) {
if ($request->ajax()) {
return response()->json(['error' => 'Not Found'], 404);
}
return response()->view('errors.missing', [], 404);
}
return parent::render($request, $e);
}
how can i resolve this problem?
Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE