public function store(Requests\SaveOfferRequest $request) { if (Gate::denies('create-offer')) { abort(403); } $violation_id = $request->input('violation_id'); $violation = Violation::findOrFail($violation_id); $offer = new Offer(); $offer->fill($request->input()); $offer->violation_id = $violation_id; $offer->pro_id = Auth::user()->id; $offer->user_id = $violation->author->id; $offer->save(); // Update violation $violation->offers++; $violation->status = 0; $violation->save(); // Send email $email = $violation->author->email; $to = $violation->author->username; $pro_name = $offer->author->username; $address = $violation_name = $violation->address1 . ', ' . $violation->city . ' (' . $violation->getOriginal('state') . ') ' . $violation->zip; $offer_id = $offer->id; $data = compact('to', 'pro_name', 'address', 'offer_id'); Mail::send('emails.newoffer', $data, function ($message) use($email) { $message->subject('You have received an offer'); $message->to($email); }); // Flash message $violation_name = $violation->address1 . ', ' . $violation->city . ' (' . $violation->getOriginal('state') . ') ' . $violation->zip; Session::flash('message', 'Your offer for violation <b>' . $violation_name . '</b> has been submitted.'); Session::flash('message-type', 'success'); // Redirect return redirect()->action('OfferController@show', [$offer->id]); }