Laravel - whereHas checking latest record of a relationship without checking others

后端 未结 4 528
悲哀的现实
悲哀的现实 2020-12-12 01:40

I have two tables that has One to Many relationship.

Bookings - (id)

booking_tasks - (id, booking_id,user_id)

one booking h

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 02:37

    Have you tried ->first() combined with reversed orderBy()?

    Like $q->where(‘user_id’,’=‘,’2’)->orderBy(‘id’,’DESC’)->first();

提交回复
热议问题