public function unsubscribe($slug) { $thread = Thread::whereSlug($slug)->firstOrFail(); $this->authorize('laraboard::thread-unsubscribe', $thread); $sub = Subscription::where('post_id', $thread->id)->where('user_id', \Auth::id())->delete(); return redirect()->back()->with('success', 'Thread subscription deleted.'); }
/** * Handle the event. * * @param PostCreated $event * @return void */ public function handle(PostCreated $event) { $subs = Subscription::where('post_id', $event->post->parent_id)->where('user_id', '!=', \Auth::id())->get(); if ($subs->count() > 0) { $users = $subs->first()->user()->whereIn('id', $subs->pluck('user_id'))->get(); if ($users->count() > 0) { Notification::send($users, new ReplyAdded($event->post)); } } }