Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dev22's avatar
Level 1

Generate Capacity Report

Hi, Everyone

	  Date     Pick Up	Return	Midnight Capacity		
	5/23/2023	33	       37	   241	
	5/24/2023	49	       27	   263	
	5/25/2023	65	      36	  292	

Ok so i have the above condition, I want to generate a report using laravel which is Capacity report, what i want to get this report, user will enter from & to date in form and based on that dates i will user the date pickup_count & return_count

I have a physical parking space for 500 cars , i have made an application in laravel for booking when i book the car it give me the date for arrival & return based on this i want to generate a report, but user will enter booking created_at date in form, long story short i want a table in my report section as above, will be show me the date number of return and nuber of pickups with remaning capacity

0 likes
1 reply
jlrdw's avatar

You can look at groupby and join examples.

I don't have your data, but an example would be something like:

$quy = Powner::query()->leftJoin('dc_pets', 'dc_powners.ownerid', '=', 'dc_pets.ownerid')
                ->select('dc_powners.ownerid', 'dc_powners.oname')
                ->selectRaw('count(dc_pets.petid) as countOfPets')
                ->groupby('dc_powners.ownerid')
                ->orderby('dc_powners.oname')
                ->get();

Results basically give:

ownerid, oname, countOfPets

Like:

5|Bob|3
4|Greg|9
2|Rob|1

Note sometimes a little trial and error is required to work out these types of queries.

Please or to participate in this conversation.