How to write sub queries in laravel 8?

  laravel, laravel-8, mysql, php
SELECT 
    posts.id,
    (select count(*) from post_likes where post_id = 13 and user_id = 12) as post_like
FROM
    posts
LIMIT 5

How to write this query in Laravel query builder?

Source: Laravel

Leave a Reply