app/Http/Controllers/MessagesController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        $messages = Message::where('salon_id', 0)->get()->load('user');
        $messages = $messages->groupBy('meeting_id');
        $messages = $messages->toArray();
        $participants = [];
        $meetings = ParticipeMeeting::where('user_id', Auth::id())->get();
        foreach($meetings as $meeting){
            $participant = ParticipeMeeting::where([
                ['meeting_id', $meeting->meeting_id],
                ['user_id', '!=', Auth::id()]
                ])->get()->first()->load('user');
            $participants[] = $participant;
        }
        return view('messages.index', [
            'messages'      => json_encode($messages),
            'participants'      => json_encode($participants)
        ]);
    }
public function index ( ) { $ messages = Message :: where ( 'salon_id' , 0 ) -> get ( ) -> load ( 'user' ) ; $ messages = $ messages -> groupBy ( 'meeting_id' ) ; $ messages = $ messages -> toArray ( ) ; $ participants = [ ] ; $ meetings = ParticipeMeeting :: where ( 'user_id' , Auth :: id ( ) ) -> get ( ) ; foreach ( $ meetings as $ meeting ) { $ participant = ParticipeMeeting :: where ( [ [ 'meeting_id' , $ meeting -> meeting_id ] , [ 'user_id' , '!=' , Auth :: id ( ) ] ] ) -> get ( ) -> first ( ) -> load ( 'user' ) ; $ participants [ ] = $ participant ; } return view ( 'messages.index' , [ 'messages' => json_encode ( $ messages ) , 'participants' => json_encode ( $ participants ) ] ) ; }
Display a listing of the resource.
Display a listing of the resource .
//dd($messages);