]> BookStack Code Mirror - bookstack/blob - app/Exceptions/NotifyException.php
Apply fixes from StyleCI
[bookstack] / app / Exceptions / NotifyException.php
1 <?php
2
3 namespace BookStack\Exceptions;
4
5 use Exception;
6 use Illuminate\Contracts\Support\Responsable;
7
8 class NotifyException extends Exception implements Responsable
9 {
10     public $message;
11     public $redirectLocation;
12
13     /**
14      * NotifyException constructor.
15      */
16     public function __construct(string $message, string $redirectLocation = '/')
17     {
18         $this->message = $message;
19         $this->redirectLocation = $redirectLocation;
20         parent::__construct();
21     }
22
23     /**
24      * Send the response for this type of exception.
25      *
26      * @inheritdoc
27      */
28     public function toResponse($request)
29     {
30         $message = $this->getMessage();
31
32         if (!empty($message)) {
33             session()->flash('error', $message);
34         }
35
36         return redirect($this->redirectLocation);
37     }
38 }