raviawasti
3 months ago
102
5
Laravel

How to show count of all subject with slug from post table?

Posted 3 months ago by raviawasti

I have two table one posts and second subject

posts table : id, subject_id, post_name , etc

subject table :id, subject_name, slug etc

Subject table content

id :1, subject_name :Science , slug :science

id :2 subject_name :Social Science ,slug:social-science

I am saving subject id in posts table like this

id -1, subject_id 2, post_name :how to become a teacher.

id -2, subject_id 1, post_name: how to learn english.

Now my problem is, i want to show count of posts for every subject like this

Science subject 10 posts see all

Math subject 13 posts see all

Social studies subject 2 posts see all

Please sign in or create an account to participate in this conversation.