Laravel/PHP Articles

Articles from Laravel/PHP sites on the web

Laravel/PHP Articles
''; }Step 2. groupBy with Raw ConditionNext, what if you want to group by birth year? Here’s the visual result for my dummy seeded data:Step 3. groupBy Raw with Boolean ConditionNow we’re getting to the “trick” of the article. How to group by condition of “born before or after 2001 year”? Here’s the result view in Blade: Adult? Amount @foreach ($results as $result) {{ $result->adult == 1 ? 'Yes' : 'No' }} {{ $result->amount }} @endforeach Here’s how it looks visually:You can use such grouping whenever you have clear condition of TRUE/FALSE, like odd/even numbers somewhere, some number is over/under etc.

Sign Up For Our Newsletter

Each Week, We curate the top Laravel/PHP articles, jobs, events and More!

We'll send you a weekly email with the latest Laravel/PHP articles, jobs and events. Please review our Code of Conduct in the meantime. Talk to you soon!