$type, 'userid' => $userid ])->orderByDesc('id'); if (empty($time)) { $builder = $builder->take(50); } else { $builder = $builder->where('created_at', '>=', Carbon::parse($time))->take(500); } return $builder->pluck('did')->toArray(); } /** * 忘记(恢复或添加数据时删除记录) * @param $type * @param $id * @param $userid * @return void */ public static function forget($type, $id, $userid): void { if (is_array($userid)) { self::where([ 'type' => $type, 'did' => $id, ])->whereIn('userid', $userid)->delete(); } else { self::where([ 'type' => $type, 'did' => $id, 'userid' => $userid, ])->delete(); } } /** * 记录(删除数据时添加记录) * @param $type * @param $id * @param $userid * @return void */ public static function record($type, $id, $userid): void { $array = is_array($userid) ? $userid : [$userid]; foreach ($array as $value) { if (!self::where('type', $type)->where('did', $id)->where('userid', $value)->exists()) { self::updateInsert([ 'type' => $type, 'did' => $id, 'userid' => $value, ]); } } } }