Skip to content

Commit

Permalink
Set the default message
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Apr 26, 2017
1 parent 9d7925c commit 1f2f130
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions src/Laracasts/Flash/FlashNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ class FlashNotifier
*
* @var SessionStore
*/
private $session;
protected $session;

/**
* Create a new flash notifier instance.
* The message being flashed.
*
* @var string
*/
protected $message = '';

/**
* Create a new FlashNotifier instance.
*
* @param SessionStore $session
*/
Expand Down Expand Up @@ -40,7 +47,7 @@ public function info($message)
* @param string $message
* @return $this
*/
public function success($message)
public function success($message = null)
{
$this->message($message, 'success');

Expand All @@ -53,7 +60,7 @@ public function success($message)
* @param string $message
* @return $this
*/
public function error($message)
public function error($message = null)
{
$this->message($message, 'danger');

Expand All @@ -66,7 +73,7 @@ public function error($message)
* @param string $message
* @return $this
*/
public function warning($message)
public function warning($message = null)
{
$this->message($message, 'warning');

Expand All @@ -76,14 +83,16 @@ public function warning($message)
/**
* Flash an overlay modal.
*
* @param string $message
* @param string $title
* @param string $level
* @param string|null $message
* @param string $title
* @param string $level
* @return $this
*/
public function overlay($message, $title = 'Notice', $level = 'info')
public function overlay($message = null, $title = 'Notice', $level = 'info')
{
$this->message($message, $level);
if ($message) {
$this->message($message, $level);
}

$this->session->flash('flash_notification.overlay', true);
$this->session->flash('flash_notification.title', $title);
Expand All @@ -100,7 +109,11 @@ public function overlay($message, $title = 'Notice', $level = 'info')
*/
public function message($message, $level = 'info')
{
$this->session->flash('flash_notification.message', $message);
if ($message) {
$this->message = $message;
}

$this->session->flash('flash_notification.message', $this->message);
$this->session->flash('flash_notification.level', $level);

return $this;
Expand Down

0 comments on commit 1f2f130

Please sign in to comment.