Understanding Eloquent
? The fundamental key to understanding Eloquent. pic.twitter.com/WkaKIFaeOR
— Caleb Porzio (@calebporzio) July 1, 2019
Read more [twitter.com]
Posts tagged with eloquent
? The fundamental key to understanding Eloquent. pic.twitter.com/WkaKIFaeOR
— Caleb Porzio (@calebporzio) July 1, 2019
Read more [twitter.com]
In the project that @freekmurze and I are working on, I needed the ability to replicate an existing Eloquent model into a different Eloquent model.
— Marcel Pociot ? (@marcelpociot) June 12, 2019
If you feel like this could be useful for you as well, here's the little trait for that:https://t.co/IXFpAsxE35 pic.twitter.com/fCccKmLdQs
Read more [twitter.com]
Join 9,500+ smart developers
Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime. You can also follow me on X.
"If you are one of the *millions* who have downloaded a Spatie package, then you understand the quality that Freek aims for. The newsletter is of the same quality of any Spatie package you're using."
?? Laravel Core Adventures - Did you know?
— Christoph Rumpel ? (@christophrumpel) May 17, 2019
Ever wondered what "hydrate" means? I've been there. Then I realized it's just a fancy word for filling an object with data.
In this Eloquent Builder example, Laravel fills a new collection object with models from an array. pic.twitter.com/D5t0EVnksM
Read more [twitter.com]
You know `firstOrFail`, `firstOrCreate`, etc in @laravel
— Jeff Madsen (@codebyjeff) May 19, 2019
There's also a simple `firstOr` that will run a callback if not found pic.twitter.com/q7QmPR1y1S
Read more [twitter.com]
A little helper method I put on my base Model class on Secret Project VI… Kinda handy. ?♂️ pic.twitter.com/mPOMV73d5L
— Taylor Otwell ? (@taylorotwell) April 30, 2019
Read more [twitter.com]
?? Laravel Core Adventures - Did you know?
— Christoph Rumpel ? (@christophrumpel) April 17, 2019
In Laravel, we can access related data as if we would call a class property. But in fact, this is just a shortcut/hack for using the relationship method we have defined.
The second approach has one advantage, your IDE can follow it. pic.twitter.com/OjL4zNqUnp
Read more [twitter.com]
Povilas Korop explains how to use a raw groupBy in Laravel. Cool!
Read more [laraveldaily.com]
Did you know that you can define a $dispatchesEvents property on your Eloquent model and map native Eloquent events to your own event classes? ? Check this out: pic.twitter.com/P205GTIYEc
— Laravel Docs Daily (@laradocsdaily) November 24, 2018
Read more [twitter.com]
There are three ways of loading relationships in Laravel. Tim MacDonald, a freelance dev based in Sydney, explains them all.
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.
Read more [timacdonald.me]
At the LaraconLive India conference, Shawn McCool shared some interesting ideas on how to handle models in complex apps.
If you want to speak at the 2019 edition of the conference, you'll be happy to learn that they currently have a CFP running.
For a project I'm working on I needed to build a lightweight, pragmatic search. In this blogpost I'd like to go over my solution. Searching Eloquent models Imagine you need to provide a search for users. Using Eloquent you can perform a search like this: User::query() ->where('name',…
My colleague Brent explains how you can easily work with MySQL views in Laravel.
MySQL views are a way of storing queries on the database level, and producing virtual tables with them. In this post we'll look at why you want to use them and how they can be integrated in Laravel with Eloquent models.
Read more [stitcher.io]
Andrew Schmelyun collected some cool Eloquent niceties.
Over the last year or so, I’ve been collecting and (sometimes) tweeting about methods and helpers I’ve stumbled across in Laravel’s Eloquent ORM. Most of these aren’t that obvious in the documentation, but have made a huge impact as my applications have grown in both size and complexity.
Read more [medium.com]
Joseph Silber, a very active Laravel contributor, has written a new blogpost on morph maps, a feature to decouple your database from your model class names.
Polymorphic relations let you set up a relationship between many different model types, without the need for extra tables. This works by storing the "morphable type" (explained below) in the database, in addition to the morphable type's ID. By default, the morphable type stored in the database is the model's full class name. While this works, it tightly couples your database to your PHP application. Let's look at how we can instruct Eloquent to use more generic values for these morphable types.
Read more [josephsilber.com]
I often use Eloquent's `query` just to have the code better aligned#visualdebtisreal pic.twitter.com/0JWrzx6wEN
— Freek Van der Herten (@freekmurze) 2 juli 2018
Read more [twitter.com]
?? Use Eloquent's "->is()" method for more expressive and thorough assertions pic.twitter.com/8zx8AEm9Rw
— Caleb Porzio (@calebporzio) 22 juni 2018
Read more [twitter.com]
? Killing conditionals with Eloquent's "firstOr" method. If firstOrCreate, firstOrFail, or firstOrNew don't quite cut it. pic.twitter.com/PKrtqDc0vl
— Caleb Porzio (@calebporzio) 22 mei 2018
Read more [twitter.com]
⏲️ Handy eloquent macro for the date comparison impaired ? pic.twitter.com/rUgLlEywrn
— Caleb Porzio (@calebporzio) April 25, 2018
Read more [twitter.com]
#30daysWithEloquent customize relations on your models as necessary in your domain. Don't be afraid to add more relations that describe your logic better.
— DRY, DRY, DRY, DRY (@SOFTonSOFA) February 22, 2018
With @laravelphp it's a cinch ??? pic.twitter.com/m3TJXp9C2l
Read more [twitter.com]
Imagine you want to have an Eloquent model hold a status. It's easily solved by just adding a status field to that model and be done with it. But in case you need a history of status changes or need to store some extra info on why a status changed, only adding a single field won't cut it. To handle…