Laravel Custom Query Builders Over Scopes
While scopes are useful for simple queries, custom query builders are preferred for complex or frequently used queries.
Read more [blog.oussama-mater.tech]
Posts tagged with query builder
While scopes are useful for simple queries, custom query builders are preferred for complex or frequently used queries.
Read more [blog.oussama-mater.tech]
– seankegel.com - submitted by Sean Kegel
Use tappable scopes in Laravel to break down complex queries into reusable pieces without needing to use magic query scopes in Laravel.
Read more [seankegel.com]
Join thousands of developers
Every two weeks, I share practical tips, tutorials, and behind-the-scenes insights from maintaining 300+ open source packages.
No spam. Unsubscribe anytime. You can also follow me on X.
– youtu.be - submitted by Bert De Swaef
Bert shows us a hidden Laravel gem!
Read more [youtu.be]
– youtu.be - submitted by Bert De Swaef
In this video we're having a look at the Query Builder, and how to use it correctly.
We're optimizing our performance by a. lot of request time, models loaded and memory used.
Read more [youtu.be]
Pretty cool that you can achieve this by executing a query, and without application logic.
Read more [sqlfordevs.com]
– postsrc.com - submitted by Sir Src
– naxon.dev - submitted by Daniel Naxon
Ever needed to apply filters on a query conditionally, only when the user actually applies them? Laravel query builder's method when got you covered.
Read more [naxon.dev]
– atymic.dev - submitted by atymic
Overview of the new upsert feature in Laravel 8.10, how to use it and some tips.
Read more [atymic.dev]
🧙♂️ One of my favorite Laravel 7 features is query time casting. This is super handy when using a subquery to get extra "non-model" data, such as a date. By default it would be a string. This feature lets you cast it to a Carbon instance "on the fly". 👌https://t.co/Kd94iMsomA pic.twitter.com/VIzowGy3um
— Jonathan Reinink (@reinink) April 15, 2020
Read more [twitter.com]
On the subscribers screens of the Mailcoach, you can filter out the subscribers that have a certain status, you can search and sort them.
In the video below, which is part of the upcoming Mailcoach video course, I explain how we built these filters, powered by three of our packages: laravel-query-builder, query-string and Blade X.
Tim MacDonald shares an interesting technique.
Action scopes are...well...just query scopes really, but instead of filtering they take an action. It's just a random name I've given them to differentiate them from regular filtering based query scopes in my projects.
Read more [timacdonald.me]
And if you're a @laravelphp user wondering how you can use this feature, you can easily extend the query builder to support this. ?
— Jonathan Reinink (@reinink) July 16, 2019
Gist here: https://t.co/Wuavz0v7p9 pic.twitter.com/Vy6NJdJbcx
Read more [twitter.com]
Jonathan Reinink wrote another awesome post on how to handle a complicated query.
I was asked recently how to calculate multiple totals (aggregates) in Laravel in the most efficient way. For example, maybe you have an email subscription service and want to display various totals based on your subscribers
Read more [reinink.ca]
Povilas Korop explains how to use a raw groupBy in Laravel. Cool!
Read more [laraveldaily.com]
#Laravel tip of the day: in Eloquent Query Builder, you can specify "as" to return any column with a different name, just like in plain SQL query. pic.twitter.com/r7xGm50lDL
— Povilas@LaravelDaily (@DailyLaravel) September 25, 2018
Read more [twitter.com]
Surprised no one knew about that, but did you know you can do this? pic.twitter.com/OfJ7udnHFe
— Mohamed Said? (@themsaid) 15 augustus 2018
? TIL Eloquent's query builder has a whereBetween function#laravel #php pic.twitter.com/SyCXshL3Oe
— Freek Van der Herten (@freekmurze) November 5, 2017
Read more [twitter.com]
?Combining query scopes with explicit model names will help keep code cleaner and easier to understand #laravel pic.twitter.com/ixzDdrZcRT
— Chris Gmyr (@cmgmyr) July 12, 2017
On Twitter I see a bunch of people regularly tweeting very nice code snippets. Instead of only retweeting those, I'm going to add them to my blog. I'll tag them with tweet.
Here's the first one:
request()->query() is a life saver when dealing with tables that store "sorts" and "filters" in a query string. pic.twitter.com/84P6xvTvSz
— Caleb Porzio (@calebporzio) June 21, 2017
Read more [twitter.com]
Over at the excellent dotdev.co Amo Chohan wrote an article on how to structure code when you need many filters on an Eloquent model.
I recently needed to implement a search feature in an events management project I was building. What begun as a few simple options (searching by name, e-mail etc), turned into a pretty large set of parameters. Today, I’ll go over the process I went through and how I built a flexible and scalable search system. For those of you who are eager to see the final code, head over to the Git repository to see the code.
https://dotdev.co/writing-advanced-eloquent-search-query-filters-de8b6c2598db