/** * Get recently added Tags from the DB based on the specified count * * @param $count * @param null|User $user * @return mixed */ public function recent($count, $user = null) { $query = Tag::query()->orderBy('created_at', 'desc')->take($count); if ($user) { $query->where('user_id', $user->id); } return $query; }