Skip to content

Instantly share code, notes, and snippets.

@dillinghamio
Last active January 18, 2019 08:14
Show Gist options
  • Save dillinghamio/027563b477f5e581253e90aff2f1a595 to your computer and use it in GitHub Desktop.
Save dillinghamio/027563b477f5e581253e90aff2f1a595 to your computer and use it in GitHub Desktop.
Notification Helper For Laravel Spark

notification Helper For Laravel Spark

The method assumes the current authenticated user, so you only need to pass the message

function notification($message)
{
	$notification = app('Laravel\Spark\Contracts\Repositories\NotificationRepository');
	
	return $notification->create(auth()->user(), $message);
}
And call it like so
notification([
    'icon' => 'fa-users',
    'body' => "Hello World",
    'action_text' => 'Click Me',
    'action_url' => "http://google.com",
]);
@dillingham
Copy link

@katieben, and others, you can add a helpers.php file to composer and use it

https://laravel-news.com/creating-helpers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment