Skip to main content

Show Error Page in Laravel in two ways

copy errors directory from resource views
-inside error directory create page 403.blade,202.blade ... same as the name inside the switch case of render function of handler.

 and

copy errormaster from layouts of resource

copy and paste code inside handler of exception folder in render function
paste the following code:
public function render($request, Exception $exception)
{
if ($this->isHttpException($exception)) {
$message = $exception->getMessage();
// dd($message);
switch ($exception->getStatusCode()) {

// not authorized
case '403':
return \Response::view('errors.403',array(compact('message')),403);
break;
case '202':
return \Response::view('errors.202',array(compact('message')),202);
break;

// not found
case '404':
return \Response::view('errors.404',array(compact('message')),404);
break;

// internal error
case '500':
return \Response::view('backend.errors.500',array(compact('message')),500);
break;

default:
return $this->renderHttpException($exception);
break;
}
} else {
return parent::render($request, $exception);
}
return parent::render($request, $exception);
}

always change  APP_debug of env file from true to false#important

default maa j xa tyo lai change app_debug thats all

 NEXT WAY:-
Simply go inside: vendor/laravel/src/illuminate/foundation/exceptions/views/404.blade.php
@extends('errors::illustrated-layout')

@section('code', '404')
@section('title', __('Page Not Found'))

@section('image')
<div style="background-image: url('/svg/404.svg');" class="absolute pin bg-cover bg-no-repeat md:bg-left lg:bg-center">
</div>
@endsection

@section('message', __('Sorry, the page you are looking for could not be found.'))

Sorry :) laravel 5.7 have provided this autometically ... but from here you can change message... by changing on the @section('message'_('custom message here'))

now its done hai ta

Best way of error handling in laravel 6 :
php artisan vendor:publish --tag=laravel-errors
then you will need to do following things:

in illustrated-layout.blade of error folder :
  <a href="{{ app('router')->has('home') ? route('home') : url('/') }}">
<button class="bg-transparent text-grey-darkest font-bold uppercase tracking-wide py-3 px-6 border-2 border-grey-light hover:border-grey rounded-lg">
{{ __('Go Home') }}
</button>
</a>


to
<a href="{{ app('router')->has('front.index') ? route('front.index') : url('/') }}">
<button class="bg-transparent text-grey-darkest font-bold uppercase tracking-wide py-3 px-6 border-2 border-grey-light hover:border-grey rounded-lg">
{{ __('Go Home') }}
</button>
</a>

now on each error page :
change the following:
@extends('errors::minimal')
to
@extends('errors::illustrated-layout')

Comments

Popular posts from this blog

laravel file manager sorting by time default

Ref :  https://github.com/UniSharp/laravel-filemanager/issues/337 To load files order by "time DESC" you can change the code in vendor/unisharp/laravel-filemanager/src/traits/LfmHelpers.php public function sortFilesAndDirectories($arr_items, $sort_type) { if ($sort_type == 'time') { $key_to_sort = 'updated'; } elseif ($sort_type == 'alphabetic') { $key_to_sort = 'name'; } else { $key_to_sort = 'updated'; } return strcmp($a->{$key_to_sort}, $b->{$key_to_sort}); }); return $arr_items; } with public function sortFilesAndDirectories($arr_items, $sort_type) { if ($sort_type == 'time') { $key_to_sort = 'updated'; } elseif ($sort_type == 'alphabetic') { $key_to_sort = 'name'; } else { $key_to_sort = 'updated';

some important points for web developers and hosting

check dns https://www.whatsmydns.net/ https://check-host.net/ https://www.site24x7.com/ping-test.html attacks https://www.computerhope.com/unix/uping.htm https://vitux.com/linux-ping-command/ https://www.howtoforge.com/linux-ping-command/ https://www.poftut.com/linux-ping-command-tutorial-examples/ https://phoenixnap.com/kb/linux-ping-command-examples https://sandilands.info/sgordon/ping-flooding-dos-attack-in-a-virtual-network https://www.geeksforgeeks.org/ping-command-in-linux-with-examples/

Installing Admin LTE in Laravel

step 1:  Reference---  https://hdtuto.com/article/laravel-56-adminlte-bootstrap-theme-installation-example Step 2 : after completion first reference view this link:    https://github.com/JeroenNoten/Laravel-AdminLTE step 3:  For more additional information view this link:   https://github.com/jeroennoten/Laravel-AdminLTE#2-updating Now you are done statically : https://adminlte.io/blog/integrate-adminlte-with-laravel Steps: 1:  composer require jeroennoten/laravel-adminlte 2: 'providers' => [ .... JeroenNoten\LaravelAdminLte\ServiceProvider::class, ], 3: php artisan vendor:publish --provider="JeroenNoten\LaravelAdminLte\ServiceProvider" --tag=assets 5: php artisan vendor:publish --provider="JeroenNoten\LaravelAdminLte\ServiceProvider" --tag=config 6: php artisan vendor:publish --provider="JeroenNoten\LaravelAdminLte\ServiceProvider" --tag=views 7: for admin pannel php artisan make:adminl