Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Tim MacDonald:
Loading Eloquent relationship counts
Nov 12, 2018 @ 15:51:30

Tim MacDonald has a new post to his site sharing methods that the Laravel Eloquent users (either in the framework or outside of it) can use to load in the counts of relationships without having to fetch the entire relationship data set.

It is often useful to show the number of related models a given instance has, but not actually need any specific information about the related models, just how many exist. In this scenario you do not want to load all of the related models into memory to count them, we want our database to do the heavy lifting for us. Laravel offers a number of ways to retrieve relationship counts. 2 have been around for a while, but there is a new kid on the block.

He looks at three methods you can use to get these counts: via the query builder manually, directly on the relationship and, more recently added, from an eloquent collection. He goes through each of these methods, providing a summary of the technique and code examples showing how it's implemented.

tagged: laravel eloquent relationship count tutorial querybuilder collection

Link: https://timacdonald.me/loading-eloquent-relationship-counts/

North Meets South Podcast:
Episode #47 - Reinventing form controls, typing ahead, and converting MyS
Sep 26, 2018 @ 16:05:40

The North Meets South podcast, hosted by PHP community members Jacob Bennett and Michael Dyrynda, has posted their latest episode - Episode #47: Reinventing form controls, typing ahead, and converting MySQLi to Query Builder

In this new show Jacob and Michael return after a hiatus during the summer to talk largely about accessibility in applications (including forms and the overall UI) and updating the Query Builder to work with MySQLi versus MySQL.

You can listen to this latest episode either using the in-page audio player or by downloading the mp3 of the show. If you enjoy it, be sure to subscribe to their feed and follow them on Twitter to stay up to date on when new shows are released.

tagged: podcast northmeetssouth ep47 form control accessibility ui querybuilder

Link: http://www.northmeetssouth.audio/47


Trending Topics: