How to index count from json in Laravel
问题 I have a messages table with Structure as follows: id sender_id receiver_id pet_id description the description is the text message. I am fetching messages of users related to a specific pet by fetching all messages where the sender is user or receiver is user and then filtering them by petId I want. function messagesByPet($petId,$userId){ $messages = Message::where('sender_id',$userId)->orWhere('receiver_id',$userId)->orderBy('created_at','asc')->get(); $message = $messages->where('pet_id',