/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $purchases = Purchase::where('user_id', Auth::user()->id)->get(); return view('purchases.index', ['purchases' => $purchases]); }
public function getHistorico() { $sale = Transaction::whereHas('book', function ($q) { $q->where('id_user', '=', \Auth::user()->id); })->get(); $sale->sum('price'); $myRental = Aluguer::whereHas('book', function ($q) { $q->where('id_user', '=', \Auth::user()->id); })->get(); $purchases = Purchase::where('user_id', '=', \Auth::user()->id)->get(); $rental = Aluguer::where('user_id', '=', \Auth::user()->id)->get(); $user = \App\User::find(\Auth::user()->id); return view('historico', ['purchases' => $purchases, 'sales' => $sale, 'rentals' => $rental, 'myRentals' => $myRental, 'user' => $user]); }