app/Http/Controllers/SalonsController.php
/**
     * Display the salon's chat
     */
Display the salon's chat
Display the salon ' s chat
public function chats() {
        $messages = [];
        $salons = [];
        $user_salons = ParticipeSalon::where('user_id', Auth::id())->get()->load('salon');
        foreach($user_salons as $p){
            $salons[] = $p->salon_id;
        }
        $messages = Message::whereIn('salon_id', $salons)->get();
        $messages = $messages->groupBy('salon_id');
        $messages = $messages->toArray();
        $messages = json_encode($messages);
        $user_salons = json_encode($user_salons);
        return view('salons.chats', compact('messages', 'user_salons'));
    }
public function chats ( ) { $ messages = [ ] ; $ salons = [ ] ; $ user_salons = ParticipeSalon :: where ( 'user_id' , Auth :: id ( ) ) -> get ( ) -> load ( 'salon' ) ; foreach ( $ user_salons as $ p ) { $ salons [ ] = $ p -> salon_id ; } $ messages = Message :: whereIn ( 'salon_id' , $ salons ) -> get ( ) ; $ messages = $ messages -> groupBy ( 'salon_id' ) ; $ messages = $ messages -> toArray ( ) ; $ messages = json_encode ( $ messages ) ; $ user_salons = json_encode ( $ user_salons ) ; return view ( 'salons.chats' , compact ( 'messages' , 'user_salons' ) ) ; }
Display the salon's chat
Display the salon ' s chat