Package Data | |
---|---|
Maintainer Username: | pyaesone17 |
Maintainer Contact: | promise286@gmail.com (Pyae Sone Nyein) |
Package Create Date: | 2017-05-24 |
Package Last Update: | 2017-05-24 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-26 15:12:37 |
Package Statistics | |
---|---|
Total Downloads: | 10 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 3 |
Total Forks: | 0 |
Total Open Issues: | 0 |
The package will allow you to define the error view based on model and based on the request.
Frontend view of Shop Model Not Found Exception
Backend view of Shop Model Not Found Exception
Via Composer
$ composer require pyaesone17/laravel-pretty-handler
Firstly register the serviceprovider in config/app.php like this
[ ....
Pyaesone17\LaravelPrettyHandler\PrettyServiceProvider::class
],
Resolve \Pyaesone17\LaravelPrettyHandler\PrettyHandler like this in the render method of App\Exceptions\Handler.
$prettyResponse = ( resolve(\Pyaesone17\LaravelPrettyHandler\PrettyHandler::class)) ($e);
if($prettyResponse){
return $prettyResponse;
}
In the model you have to implement \Pyaesone17\LaravelPrettyHandler\Pretty trait and set up using setUp method.
prettyDefaultView will be default view of the App\User not found exception.
prettyRules will accept the array list with url and view.
In the following example, if the exception occurs in admin section errors.backend page will show.
If request does not match any url value, it will show default page of the Model that is defined in prettyDefaultView.
class User extends Model
{
use Pretty;
public function setUpPretty()
{
$this->prettyDefaultView = 'errors.coming';
$this->prettyRules = [
['url' => 'admin/*','view' => 'errors.backend'],
['url' => 'frontend/*','view' => 'errors.frontend'],
['url' => 'shop/*', 'view' => 'errors.coming']
];
}
}
Do not use \Pyaesone17\LaravelPrettyHandler\PrettyHandler::class directly in Handler because it recieve constructor value from the Service Container.
You have to resolve the class fromn the container.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING and CONDUCT for details.