/** * Display a listing of the resource. * * @return Response */ public function index($id) { // $file = Files::where('id', $id)->get(); $author = Artists::where('id', $file[0]->created_by)->get(); $buys = Buys::where('file_id', '=', $file[0]->id)->where('buyed_by', '=', Auth::user()->id)->get(); return view('song')->with('song', $file)->with('author', $author)->with('buys', $buys); }
/** * 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); }