/** * Display a listing of the resource. * * @return Response */ public function index($id) { $current_user = User::find($id); $buys = Buys::where('buyed_by', '=', $id)->select('file_id')->get(); $cont = 0; $arr_id[$cont] = 0; foreach ($buys as $buy) { $arr_id[$cont] = $buy->file_id; $cont++; } $songs = Files::whereIn('id', $arr_id)->get(); return view('user')->with('songs', $songs)->with('current_user', $current_user); }