Beispiel #1
0
 public static function sendNotification($user_id, $type, $title, $text)
 {
     // Generate a hash to lookup
     $hash = BaseNotify::makeNotificationHash($user_id, $type, $title, $text);
     // Check the existance of the hash in the notifications table
     if (!\SeatNotification::where('hash', '=', $hash)->exists()) {
         // Send the new noticiation
         $notification = new \SeatNotification();
         $notification->user_id = $user_id;
         $notification->type = $type;
         $notification->title = $title;
         $notification->text = $text;
         $notification->hash = $hash;
         $notification->save();
         // Check if the user is configured to receive the
         // notifications via email
         if (SettingHelper::getSetting('email_notifications', false, $user_id) == 'true') {
             // Prepare data to be sent along with the email. These
             // are accessed by their keys in the email template
             $data = array('type' => $type, 'title' => $title, 'text' => $text, 'notification_id' => $notification->id);
             // Send the notifications email
             \Mail::send('emails.notifications.notify', $data, function ($message) use($user_id, $title) {
                 $message->to(\Auth::findUserById($user_id)->email, \Auth::findUserById($user_id)->username)->subject('New SeAT ' . $title . ' notification.');
             });
         }
         return true;
     }
     return false;
 }
 public function getMarkUnread($notificationID)
 {
     $notification = \SeatNotification::find($notificationID);
     if ($notification->user_id == Auth::User()->id) {
         $notification->read = 0;
         $notification->save();
         return Redirect::action('NotificationController@getAll')->with('success', 'Notification "' . $notification->title . '" marked as unread');
     } else {
         App::abort(403);
     }
 }