From 5ee8dd8e723f63b1dd969b26bff16fb3099b68ca Mon Sep 17 00:00:00 2001 From: Laracasts Date: Sun, 1 Feb 2015 14:41:37 -0500 Subject: [PATCH] Make fluent, and add "important" flag --- src/Laracasts/Flash/FlashNotifier.php | 43 ++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/Laracasts/Flash/FlashNotifier.php b/src/Laracasts/Flash/FlashNotifier.php index 32d1175..ceba1d5 100644 --- a/src/Laracasts/Flash/FlashNotifier.php +++ b/src/Laracasts/Flash/FlashNotifier.php @@ -28,43 +28,55 @@ function __construct(SessionStore $session) public function info($message) { $this->message($message, 'info'); + + return $this; } /** * Flash a success message. * - * @param string $message + * @param string $message + * @return $this */ public function success($message) { $this->message($message, 'success'); + + return $this; } /** * Flash an error message. * - * @param string $message + * @param string $message + * @return $this */ public function error($message) { $this->message($message, 'danger'); + + return $this; } /** * Flash a warning message. * - * @param string $message + * @param string $message + * @return $this */ public function warning($message) { $this->message($message, 'warning'); + + return $this; } /** * Flash an overlay modal. * - * @param string $message - * @param string $title + * @param string $message + * @param string $title + * @return $this */ public function overlay($message, $title = 'Notice') { @@ -72,18 +84,35 @@ public function overlay($message, $title = 'Notice') $this->session->flash('flash_notification.overlay', true); $this->session->flash('flash_notification.title', $title); + + return $this; } /** * Flash a general message. * - * @param string $message - * @param string $level + * @param string $message + * @param string $level + * @return $this */ public function message($message, $level = 'info') { $this->session->flash('flash_notification.message', $message); $this->session->flash('flash_notification.level', $level); + + return $this; + } + + /** + * Add an "important" flash to the session. + * + * @return $this + */ + public function important() + { + $this->session->flash('flash_notification.important', true); + + return $this; } }