public function postContact(Request $request) { $auction = Art::findorfail($request->input('auction'))->first(); $auctionEmail = $auction->user->email; $data['receiver'] = $auctionEmail; $data['sender'] = $request->input('email'); $data['question'] = $request->input('question'); // send mail to owner of art Mail::send('emails.question', $data, function ($message) use($data) { $message->to($data['receiver'])->subject('I have a question about your auction'); }); return redirect()->route('home'); }
public function buyNow($id) { $art = Art::findorfail($id); if ($art->sold()->count() > 0) { return redirect()->back()->withErrors(['this item was already sold']); } $buyer = Auth::user(); $sold = new Sold(); $sold->art_id = $art->id; $sold->buyer_id = $buyer->id; $sold->save(); $art->sold = 1; $art->save(); $data['art'] = $art; return View('Art.bought')->with($data); }