]> BookStack Code Mirror - bookstack/blobdiff - app/Exceptions/NotifyException.php
Minor capitalisation fix for Estonian
[bookstack] / app / Exceptions / NotifyException.php
index c9ff9975dca1e5dc9919313922234869a01df44e..ef9a441010f687ba66325fb061a1237ae253e737 100644 (file)
@@ -1,21 +1,38 @@
-<?php namespace Oxbow\Exceptions;
+<?php
 
+namespace BookStack\Exceptions;
 
-class NotifyException extends \Exception
-{
+use Exception;
+use Illuminate\Contracts\Support\Responsable;
 
+class NotifyException extends Exception implements Responsable
+{
     public $message;
     public $redirectLocation;
 
     /**
      * NotifyException constructor.
-     * @param string $message
-     * @param string    $redirectLocation
      */
-    public function __construct($message, $redirectLocation)
+    public function __construct(string $message, string $redirectLocation = '/')
     {
         $this->message = $message;
         $this->redirectLocation = $redirectLocation;
         parent::__construct();
     }
-}
\ No newline at end of file
+
+    /**
+     * 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);
+    }
+}