/** * Show the form for creating a new resource. * * @return Response */ public function buy($id) { // $file = Files::where('id', $id)->get(); if (Auth::user()->money < $file[0]->price) { return redirect()->back()->with('errors', 'You need more caaashhhh'); } else { $user = User::find(Auth::user()->id); $user->money = $user->money - $file[0]->price; $user->save(); $buy = new Buys(); $buy->buyed_by = Auth::user()->id; $buy->file_id = $id; $buy->save(); return redirect()->back(); } }