📜  Laravel 高级子查询 - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:25.343000             🧑  作者: Mango

代码示例1
use App\Models\Destination;
use App\Models\Flight;

return Destination::addSelect(['last_flight' => Flight::select('name')
    ->whereColumn('destination_id', 'destinations.id')
    ->orderByDesc('arrived_at')
    ->limit(1)
])->get();