Skip to content

Commit

Permalink
✨ Add custom title to default notification
Browse files Browse the repository at this point in the history
  • Loading branch information
mckenziearts committed Feb 22, 2020
1 parent 7ec10c3 commit 52ee9b6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
2 changes: 1 addition & 1 deletion resources/views/messages.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="notify-alert notify-{{ session()->get('notify.type') }} {{ config('notify.theme') }} animated {{ config('notify.animate.in_class') }}" role="alert">
<div class="notify-alert-icon"><i class="{{ session()->get('notify.icon') }}"></i></div>
<div class="notify-alert-text">
<h4>{{ session()->get('notify.type') }}</h4>
<h4>{{ session()->get('notify.title') ?? session()->get('notify.type') }}</h4>
<p>{{ session()->get('notify.message') }}</p>
</div>
<div class="notify-alert-close">
Expand Down
20 changes: 12 additions & 8 deletions src/LaravelNotify.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ public function __construct(Session $session)
* Flash an information message.
*
* @param string $message
* @param string|null $title
* @return $this
*/
public function info(string $message): self
public function info(string $message, string $title = null): self
{
$this->flash($message, 'info', 'flaticon-exclamation-1', 'toast');
$this->flash($message, 'info', 'flaticon-exclamation-1', 'toast', $title);

return $this;
}
Expand All @@ -42,11 +43,12 @@ public function info(string $message): self
* Flash a success message.
*
* @param string $message
* @param string|null $title
* @return $this
*/
public function success(string $message): self
public function success(string $message, string $title = null): self
{
$this->flash($message, 'success', 'flaticon2-check-mark', 'toast');
$this->flash($message, 'success', 'flaticon2-check-mark', 'toast', $title);

return $this;
}
Expand All @@ -55,11 +57,12 @@ public function success(string $message): self
* Flash an error message.
*
* @param string $message
* @param string|null $title
* @return $this
*/
public function error(string $message): self
public function error(string $message, string $title = null): self
{
$this->flash($message, 'error', 'flaticon2-delete', 'toast');
$this->flash($message, 'error', 'flaticon2-delete', 'toast', $title);

return $this;
}
Expand All @@ -68,11 +71,12 @@ public function error(string $message): self
* Flash a warning message.
*
* @param string $message
* @param string|null $title
* @return $this
*/
public function warning(string $message): self
public function warning(string $message, string $title = null): self
{
$this->flash($message, 'warning', 'flaticon-warning-sign', 'toast');
$this->flash($message, 'warning', 'flaticon-warning-sign', 'toast', $title);

return $this;
}
Expand Down
23 changes: 12 additions & 11 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
/**
* Notify.
*
* @param string|null $message
* @param string|null $message
* @param string|null $title
* @return \Mckenziearts\Notify\LaravelNotify
*/
function notify(string $message = null)
function notify(string $message = null, string $title = null)
{
$notify = app('notify');

if (! is_null($message)) {
return $notify->success($message);
return $notify->success($message, $title);
}

return $notify;
Expand All @@ -23,9 +24,9 @@ function notify(string $message = null)
/**
* Connectify.
*
* @param string $type
* @param string $title
* @param string $message
* @param string $type
* @param string $title
* @param string $message
* @return \Mckenziearts\Notify\LaravelNotify
*/
function connectify(string $type, string $title, string $message)
Expand All @@ -40,7 +41,7 @@ function connectify(string $type, string $title, string $message)
/**
* Drakify.
*
* @param string $type
* @param string $type
* @return \Mckenziearts\Notify\LaravelNotify
*/
function drakify(string $type)
Expand All @@ -55,8 +56,8 @@ function drakify(string $type)
/**
* Smilify.
*
* @param string $type
* @param string|null $message
* @param string $type
* @param string|null $message
* @return \Mckenziearts\Notify\LaravelNotify
*/
function smilify(string $type, string $message)
Expand All @@ -70,8 +71,8 @@ function smilify(string $type, string $message)
/**
* Emotify.
*
* @param string $type
* @param string|null $message
* @param string $type
* @param string|null $message
* @return \Mckenziearts\Notify\LaravelNotify
*/
function emotify(string $type, string $message)
Expand Down

0 comments on commit 52ee9b6

Please sign in to comment.