Eloquent Query Live-Coding Example: Get Latest Viewed Posts
Real-life example of Eloquent query that may be written more efficiently. So we’re getting from bad example to good one.
What we’ll cover:
- How to perform query in raw SQL
- How to re-write it to Eloquent
- How to transform the result collection to return exactly the structure we need
If you want more practical examples like this (or a separate course, maybe?), let me know in the comments.
- - - - -
Our daily Laravel blog:
Our 50 Laravel tips in a FREE e-book:
28 views
415
135
2 months ago 00:09:40 4
Laravel Conventions/Guidelines from IxDF
3 months ago 00:04:02 1
NEW in Laravel : Eloquent Inverse Relations to Avoid N+1 Query
4 months ago 00:07:41 2
Laravel DB: Query BelongsTo 2-Levels Up - Direct Column?
4 months ago 00:05:00 2
8 Laravel Tools to Debug SQL Queries
5 months ago 00:03:51 1
Using whereAny() for cleaner queries in Eloquent | Laravel | Tutorial | Quick Win Wednesday #QWW