public function store($offer_id, Request $request) { $offer = Offer::findOrFail($offer_id); if (Gate::denies('close-offer', $offer)) { abort(403); } $rate = new Rate(); $rate->fill($request->input()); $rate->pro_id = Auth::user()->id; $rate->offer_id = $offer_id; $rate->save(); $offer->status = 6; $offer->save(); // Send email $violation = $offer->violation; $violation->status = 6; $violation->save(); $email = $offer->author->email; $to = $offer->author->username; $customer_name = $offer->violation->author->username; $address = $violation_name = $violation->address1 . ', ' . $violation->city . ' (' . $violation->getOriginal('state') . ') ' . $violation->zip; $offer_id = $offer->id; $data = compact('to', 'customer_name', 'address', 'offer_id'); Mail::send('emails.offerclosed', $data, function ($message) use($email) { $message->subject('You have been reviewed!'); $message->to($email); }); // Flash message Session::flash('message', 'You have submitted a review and closed this offer.'); Session::flash('message-type', 'success'); // Redirect return redirect()->action('OfferController@show', [$offer_id]); }
public function postImport(Request $request) { $supplier = Input::get('supplier'); $commission = Input::get('commission'); $file = Input::file('rate'); //GDF Suez if ($supplier == 'GDF Suez') { Excel::selectSheets('Price Matrix'); Excel::load($file, function ($reader) { $reader->noHeading(); $reader->skip(4)->take(4875); $reader->get(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)); $reader->setDateColumns(2); $reader->each(function ($row) { $rate = new Rate(); $rate->price = $row[8] + $commission; $rate->min_usage = 100000; $rate->max_usage = 399999; $rate->start_date = $row[2]; $rate->supplier = 'GDF Suez'; $rate->term = $row[7]; $rate->utility = $row[4]; //map utilities $rate->state = $row[3]; $rate->rate_class = $row[6]; //handle multiple rate classes $rate->load_zone = $row[5]; $rate->created_at = Carbon::now(); $rate->updated_at = Carbon::now(); $rate->save(); }); $reader->each(function ($row) { $rate = new Rate(); $rate->price = $row[9] + $commission; $rate->min_usage = 400000; $rate->max_usage = 599999; $rate->start_date = $row[2]; $rate->supplier = 'GDF Suez'; $rate->term = $row[7]; $rate->utility = $row[4]; //map utilities $rate->state = $row[3]; $rate->rate_class = $row[6]; //handle multiple rate classes $rate->load_zone = $row[5]; $rate->created_at = Carbon::now(); $rate->updated_at = Carbon::now(); $rate->save(); }); $reader->each(function ($row) { $rate = new Rate(); $rate->price = $row[10] + $commission; $rate->min_usage = 600000; $rate->max_usage = 799999; $rate->start_date = $row[2]; $rate->supplier = 'GDF Suez'; $rate->term = $row[7]; $rate->utility = $row[4]; //map utilities $rate->state = $row[3]; $rate->rate_class = $row[6]; //handle multiple rate classes $rate->load_zone = $row[5]; $rate->created_at = Carbon::now(); $rate->updated_at = Carbon::now(); $rate->save(); }); $reader->each(function ($row) { $rate = new Rate(); $rate->price = $row[11] + $commission; $rate->min_usage = 800000; $rate->max_usage = 999999; $rate->start_date = $row[2]; $rate->supplier = 'GDF Suez'; $rate->term = $row[7]; $rate->utility = $row[4]; //map utilities $rate->state = $row[3]; $rate->rate_class = $row[6]; //handle multiple rate classes $rate->load_zone = $row[5]; $rate->created_at = Carbon::now(); $rate->updated_at = Carbon::now(); $rate->save(); }); }); } elseif ($supplier == 'First Point Power') { Excel::selectSheets('All_States'); Excel::load($file, function ($reader) use($commission) { $reader->noHeading(); $reader->skip(11)->take(1152); $reader->get(array(3, 4, 5, 6, 7, 8, 9, 10)); $reader->each(function ($row) use($commission) { $rate = new Rate(); $rate->supplier = 'First Point Power'; $rate->term = $row[9]; $rate->price = $commission + $row[10] * 100; $rate->utility = strtoupper($row[6]); $rate->state = $row[5]; $rate->rate_class_group = $row[8]; //map load zones if ($row[7] == 'NEMASSBOST') { $rate->load_zone = 'NEMA'; } elseif ($row[7] == 'SEMASS') { $rate->load_zone = 'SEMA'; } else { $rate->load_zone = $row[7]; } $rate->min_usage = 0; $rate->max_usage = 400000; $rate->start_date = $row[3]; $rate->end_date = $row[4]; $rate->created_at = Carbon::now(); $rate->updated_at = Carbon::now(); $rate->save(); }); }); } else { } return redirect('admin/rates'); }