/**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     $notifications = Notification::all();
     foreach ($notifications as $notification) {
         $notification->update(['object_type' => snake_case($notification->object_type)]);
     }
 }
 /**
  * Handle the event.
  *
  * @param  ReplyWasDeleted  $event
  * @return void
  */
 public function handle($event)
 {
     $name = class_basename($event->notifiable);
     $type = snake_case($name);
     Notification::where('object_type', $type)->where('object_id', $event->notifiable->id)->delete();
     //jeigu strukturoje veikia paminejimu notificationai
     //istrinam notificationus
     //ir paminejimus
     if (in_array($type, $this->mentionable)) {
         Notification::where('object_type', 'mention')->where('object_id', $event->notifiable->id)->delete();
         Mention::where('object_type', $name)->where('object_id', $event->notifiable->id)->delete();
     }
 }
Exemple #3
0
 public static function notify($type, $object, $receiver)
 {
     $user = Auth::user();
     $notification = Notification::create(['user_id' => $receiver->id, 'from_id' => $user->id, 'object_type' => $type, 'object_id' => $object->id]);
     //jeigu notificationas ne mums patiems, padidinam notification count
     //ir triggerinam send mail eventa.
     if ($receiver->id != $user->id) {
         $receiver->increment('notification_count');
         if ($receiver->email_replies) {
             event(new UserWasNotified($object, $receiver));
         }
     }
     return $notification;
 }
Exemple #4
0
 public function show(Request $request, $slug)
 {
     $user = User::where('slug', $slug)->firstOrFail();
     $sort = $request->input('rodyti', 'visi');
     switch ($sort) {
         case 'temos':
             $items = Notification::activities($user->id)->has('topic')->with('object')->latest()->topics()->paginate('10');
             break;
         case 'pranesimai':
             $items = Notification::activities($user->id)->has('reply.topic')->with('object')->latest()->replies()->paginate('10');
             break;
         case 'busenos':
             $items = Notification::activities($user->id)->has('status')->with('object')->latest()->statuses()->paginate('10');
             break;
         default:
             $items = Notification::activities($user->id)->hasAll()->with('object')->latest()->paginate('10');
             break;
     }
     return view('user.show', compact('user', 'items', 'sort'));
 }