How to count table column type in Laravel 5.6?

Posted 6 months ago by Sunpower

working with Laravel 5.6 and mysql. I have following table name as project

id  name  number   type  
1   def        123            Car
2   lki         589           Van
3   loi         256           Truck
4   oiu       569           Car
5   hyy      589            Van

Now I need count number of each type columns values. I do not wanna loop count. just I need count each Type and show on sidemenu file. like this,

Car 2
Van 2
Truck 1

my sidemenu.blade.php file location is,


and I am going to side bar include with each blade files as following,

<div class="col-md-3 ">

then how can code my project controller to grap above type data counts and print in side the sidemenu blade file?

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

Reply to

Use Markdown with GitHub-flavored code blocks.