i wanna get the reservations that their status aren’t canceled or if status is canceled it check they have unread messages or not
Can you help me?
class Reservation extends Model
{
public function unreadMessages() {
return $this->hasMany(Message::class, 'reservation_id', 'id')
->where('read', 0);
}
}
2
Answers
use where callback method
try this
Remove the condition for the model and implement it in the way mentioned in the query.