BookStack/app/Exceptions/NotifyException.php
Dan Brown f77236aa38
Laravel 7.x Shift (#3011)
* Apply Laravel coding style
* Shift bindings
* Shift core files
* Shift to Throwable
* Add laravel/ui dependency
* Shift Eloquent methods
* Shift config files
* Shift Laravel dependencies
* Shift cleanup
* Shift test config and references
* Applied styleci changes
* Applied fixes post shift to laravel 7

Co-authored-by: Shift <shift@laravelshift.com>
2021-10-26 22:04:18 +01:00

39 lines
819 B
PHP

<?php
namespace BookStack\Exceptions;
use Exception;
use Illuminate\Contracts\Support\Responsable;
class NotifyException extends Exception implements Responsable
{
public $message;
public $redirectLocation;
/**
* NotifyException constructor.
*/
public function __construct(string $message, string $redirectLocation = '/')
{
$this->message = $message;
$this->redirectLocation = $redirectLocation;
parent::__construct();
}
/**
* Send the response for this type of exception.
*
* {@inheritdoc}
*/
public function toResponse($request)
{
$message = $this->getMessage();
if (!empty($message)) {
session()->flash('error', $message);
}
return redirect($this->redirectLocation);
}
}