Only show published items in the popular list

This commit is contained in:
Daniel_I_Am 2021-09-02 12:59:27 +02:00
parent e69b7df500
commit d9b3012153

View File

@ -59,13 +59,14 @@ class BlogArticleController extends Controller
*/
public function popular()
{
$query = BlogArticle::orderBy('views', 'desc')->orderBY('date', 'desc');
$data = BlogArticle::select()
->orderBy('views', 'desc')
->orderBy('date', 'desc')
->where('published', true)
->limit(5)
->get()
;
if (!$this->authService->isAuthenticated()) {
$query = $query->where('published', true);
}
$data = $query->limit(5)->get();
return response()->json($data);
}