Yunus Shaikhyunus.in·Jan 1, 2023How to get a single record from hasMany Relation in Laravel in the most efficient way.$users = User::query()->addSelect([ 'last_ordered_at' => Order::select("created_at") ->whereColumn('user_id', 'users.id') ->latest() ->take(1), ])->orderBy('name')->paginate(); Cons...2 likes·110 readsLaravelAdd a thoughtful commentNo comments yetBe the first to start the conversation.