You can use addSelect() in Eloquent statement, and do some calculation to that added column.
return Destination::addSelect(['last_flight' => Flight::select('name') ->whereColumn('destination_id', 'destinations.id') ->orderBy('arrived_at', 'desc') ->limit(1)])->get();
Enjoyed This Tip?
Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.
Recent Courses on Laravel Daily
[NEW] Practical Laravel Security: Packages, Secrets, Supply-Chain Attacks
7 lessons
43 min read
Roles and Permissions in Laravel 13
14 lessons
57 min
Testing in Laravel 13 For Beginners
26 lessons
1 h 41 min read