app/Http/Controllers/ConnectionsController.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()
    {
        $connections = Connection::where('user_id', auth()->id())->get();
        $user_list = [];
        foreach($connections as $connection){
            array_push($user_list, User::where('id', $connection["connected_user"])->get()[0]);
        }
        $connections = Connection::where('connected_user', auth()->id())->get();
        foreach($connections as $connection){
            array_push($user_list, User::where('id', $connection["user_id"])->get()[0]);
        }
        return response()->json($user_list, 200);
    }
public function index ( ) { $ connections = Connection :: where ( 'user_id' , auth ( ) -> id ( ) ) -> get ( ) ; $ user_list = [ ] ; foreach ( $ connections as $ connection ) { array_push ( $ user_list , User :: where ( 'id' , $ connection [ " connected_user " ] ) -> get ( ) [ 0 ] ) ; } $ connections = Connection :: where ( 'connected_user' , auth ( ) -> id ( ) ) -> get ( ) ; foreach ( $ connections as $ connection ) { array_push ( $ user_list , User :: where ( 'id' , $ connection [ " user_id " ] ) -> get ( ) [ 0 ] ) ; } return response ( ) -> json ( $ user_list , 200 ) ; }
Display a listing of the resource.
Display a listing of the resource .
// Add total users to list // Get user returns array, get first find of array // Add total users to list // Get user returns array, get first find of array