public function notifyReply($event) { $topic = $event->topic->fresh(); $userIds = model_pluck(TopicWatch::where(['topic_id' => $topic->topic_id, 'notify_status' => false]), 'user_id'); foreach (User::whereIn('user_id', $userIds)->get() as $user) { if (!present($user->user_email)) { continue; } if ($user->user_id === $topic->last_poster_id) { continue; } if (!priv_check_user($user, 'ForumTopicWatchAdd', $topic)->can()) { continue; } Mail::queue(['text' => i18n_view('emails.forum.new_reply')], compact('topic', 'user'), function ($message) use($topic, $user) { $message->to($user->user_email); $message->subject(trans('forum.email.new_reply', ['title' => $topic->topic_title])); }); TopicWatch::where(['topic_id' => $topic->topic_id, 'user_id' => $user->user_id])->update(['notify_status' => true]); } }
function priv_check($ability, $args = null) { return priv_check_user(Auth::user(), $ability, $args); }