has('workorder') ->where(function ($query) use ($pointType) { $query->where('point_id',Admin::user()->id) ->where('point_type',$pointType); }) ->where('is_read', 0); $count = $builder->count(); $res = $builder ->whereIn('id', $cacheNoticeIds) ->pluck('id') ->toArray(); $cacheNoticeIds = array_diff($cacheNoticeIds, $res); Cache::forever('w_order_notice', json_encode($cacheNoticeIds)); $notice = empty($res) ? 0 : 1; return json_encode(['notice' => $notice, 'badge' => $count]); } public function cacheWOrderNotice($id) { $cacheNotice = Cache::get('w_order_notice', '[]'); $cacheNoticeIds = json_decode($cacheNotice, true); $cacheNoticeIds[] = $id; Cache::forever('w_order_notice', json_encode($cacheNoticeIds)); } }