Category: Laravel

In this series, I show you new features and improvements to the Laravel framework since the original release of version 8. This week is about the Database and Eloquent features in Laravel 8. The team added so many great improvements to the weekly versions that I split the Database and Eloquent features into two blog posts.

The explain() method allows you to receive the explanation from the builder (both Query and Eloquent).

You may add additional constraints to each of these queries using the MorphTo relation's constrain method: use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\MorphTo; $comments = Comment::with(['commentable' => function (MorphTo $morphTo) { $morphTo->constrain([ Post::class => function (Builder $query) { $query->whereNull('hidden_at'); }, Video::class => function (Builder $query) { $query->where('type', 'educational'); }, ]); }])->get(); v8.17.2 Added BelongsToMany::orderByPivot() (https://github.com/laravel/framework/pull/35455)
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners