Skip to content

Instantly share code, notes, and snippets.

@ahmadshah
Created May 9, 2014 18:54
Show Gist options
  • Save ahmadshah/d66932938dd134a5521c to your computer and use it in GitHub Desktop.
Save ahmadshah/d66932938dd134a5521c to your computer and use it in GitHub Desktop.
Orchestra notifier trait
<?php
use Ochestra\Model\User;
use Orchestra\Support\Facades\Notifier;
trait NotifiableTrait {
/**
* Send email notification to user
*
* @param Orchestra\Model\User $user
* @param string $subject
* @param string $view
* @param array $data
* @return boolean
*/
protected function sendNotification(User $user, $subject, $view, array $data)
{
$data = array_add($data, 'user', $user->toArray());
$message = new Fluent([
'subject' => $subject,
'view' => $view,
'data' => $data
]);
$sent = Notifier::send($user, $message);
return ($sent) ? true : false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment