Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function getCompanyUnread(int $companyId)
- {
- return Channel::select(['channels.offer_id', DB::raw('COUNT(distinct messages.channel_id) as count_messages')])
- ->leftJoin('messages','messages.channel_id', '=', DB::raw('channels.id AND messages.author != "system"'))
- ->where('channels.company_id', $companyId)
- ->where(function ($query) {
- return $query->where('channels.employer_read_time', '<', DB::raw('messages.twilio_created_at'))
- ->orWhereNull('channels.employer_read_time');
- })
- ->groupBy('channels.offer_id')
- ->get()
- ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement