--- title: 'Use the withAggregate() method to add related values to Eloquent queries using subselects' tweet_id: '1459206734686277633' thread_slug: weekly-thread-2021-45 author_username: pascalbaljet images: - 'https://pbs.twimg.com/media/FDrLzISXoAEuCPm.jpg' created_at: 2021-11-12T17:09:30+00:00 slug: use-the-withaggregate-method-to-add-related-values-to-eloquent-queries-using-subselects --- 💡 A little #Laravel tip from the latest blog post to get the week started! Under the hood, the withAvg/withCount/withSum and other methods in Eloquent use the 'withAggregate' method. You can use this method to add a subselect based on a relationship 💫 #PHP #webdev #OpenSource