shlogg · Early preview
Paul Redmond @paulredmond

Eloquent JoinWith Package For Efficient Queries

Join existing Eloquent model relationships with a single query using @msafadi's JoinWith package, reducing queries from 2 to 1 for faster performance.

The Eloquent JoinWith package by Mohammed Safadi lets you join existing HasOne and BelongsTo model relationships with a new joinWith() method. According to the package's readme, JoinWith will execute a single query instead of two separate queries, which can translate to faster and more efficient queries.
To use this package, you can either use the package's JoinWith trait or extend the package's provided JoinWithModel class:
namespace App\Models; use Illuminate\Database\Eloquent\Model;use Safadi\EloquentJoinWith\Database\Concerns\JoinWith; class User extends Model{    use JoinWith;     // ...}...