getKey()], ['messageable_type', '=', $participant->getMorphClass()], ['is_seen', '=', 0], ])->get(); } public static function createCustomNotifications($message, $conversation) { $notification = []; foreach ($conversation->participants as $participation) { $is_sender = ($message->participation_id == $participation->id) ? 1 : 0; $notification[] = [ 'messageable_id' => $participation->messageable_id, 'messageable_type' => $participation->messageable_type, 'message_id' => $message->id, 'participation_id' => $participation->id, 'conversation_id' => $conversation->id, 'is_seen' => $is_sender, 'is_sender' => $is_sender, 'created_at' => $message->created_at, ]; } self::insert($notification); } public function markAsRead() { $this->is_seen = 1; $this->update(['is_seen' => 1]); $this->save(); } }