Skip to content
Advertisement

Laravel multiple count in 1 Query

Im new to this Framework, i dont know how to optimize it using db::raw count and aliases and display it to my blade.php using @foreach

im trying to optimize my code, my goals is to count pallet_conditions and store it to my aliases, i dont want to count it one by one like what i did on this code

this is my code not optimize:

JavaScript

this is the code, what i wanted to learn. just to minimize, and use aliases

JavaScript

Advertisement

Answer

Try to pass a closure like so:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement