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]); }
/** * * * @return Response */ public function getContractForm($id) { /*$cookie = Cookie::queue('rate', $id, 60);*/ $id = $id; $rates = Rate::select('id', 'term', 'supplier', 'price')->where('id', '=', $id)->get(); return view('contracts.create', compact('rates')); }
public function ajaxRateInfo(Request $request) { /*$rate_id = $request->rate_id; $rate = Rate::where('id', '=', $rate_id)->get(); return Response::json($rate);*/ $rate_id = $request->rate_id; $rate = Rate::where('id', '=', $rate_id)->firstOrFail(); $price = number_format($rate->price, 2); if ($rate->period == 'day') { $expirationDate = Carbon::today()->addDays($rate->period_count)->format('F d\\, Y'); } else { if ($rate->period == 'month') { $expirationDate = Carbon::today()->addMonths($rate->period_count)->subDay()->format('F d\\, Y'); } else { if ($rate->period == 'year') { $expirationDate = Carbon::today()->addYears($rate->period_count)->subDay()->format('F d\\, Y'); } } } /*if($rate_id == 2) { $expirationDate = Carbon::today()->addMonth()->format('F d\\, Y'); } else if($rate_id == 6) { $expirationDate = Carbon::today()->addYear()->subDay()->format('F d\\, Y'); }*/ return Response::json(['price' => $price, 'expirationDate' => $expirationDate]); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // parent::boot($router); /*Route::model*/ /** * Route model binding altering default logic * $router->bind('articles',function($id){ * return \App\Article::published()->findOrFail($id); * }); */ /*Using wildcard*/ /*$router->model('articles','App\Article');*/ $router->bind('articles', function ($id) { return \App\Article::published()->findOrFail($id); }); $router->bind('rates', function ($id) { return \App\Rate::where('id', $id)->firstOrFail(); }); $router->bind('customers', function ($id) { return \App\Customer::where('id', $id)->firstOrFail(); }); $router->bind('tags', function ($name) { return \App\Tag::where('name', $name)->firstOrFail(); }); $router->bind('motherboards', function ($name) { return \App\Motherboard::where('name', $name)->firstOrFail(); }); }
/** * Get rates that match request parameters. * * @return array */ public function getRates($request) { $zip_code = $request['zip_code']; $utility = $request['utility']; $rate_class = $request['rate_class']; $start_date = $request['start_date']; $usage = intval(preg_replace('/[^\\d.]/', '', $request['usage'])); $load_zone = Load_Zone::select('load_zones.load_zone')->join('load_zone_zip', 'load_zones.load_zone', '=', 'load_zone_zip.load_zone')->where('load_zone_zip.zip_code', '=', $zip_code)->pluck('load_zone'); $rate_class_group = Rate_Class::select('rate_class_group')->where('rate_class', '=', $rate_class)->pluck('rate_class_group'); $rates = Rate::select('id', 'term', 'supplier', 'price')->whereIn('price', function ($q) use($load_zone, $utility, $rate_class, $rate_class_group, $usage, $start_date) { $q->from('rates')->selectRaw('min(price)')->where('load_zone', '=', $load_zone)->where('utility', '=', $utility)->where('min_usage', '<=', $usage)->where('max_usage', '>=', $usage)->where('rate_class_group', '=', $rate_class_group)->orwhere('rate_class', '=', $rate_class)->orwhere('rate_class', '=', NULL)->groupBy('term'); })->groupBy('term')->orderBy('term', 'asc')->get(); return $rates; }
/** * Bootstrap any application services. * * @return void */ public function boot() { // Validator::extend('duplicate_contract', function ($attribute, $account, $parameters, $validator) { $id = array_get($validator->getData(), $parameters[0], 'id'); $today = Carbon::today('US/Eastern'); $utility = Rate::select('utility')->where('id', '=', $id)->pluck('utility'); $end_date = Rate::select('rates.id')->join('contracts', 'rates.id', '=', 'contracts.rate_id')->where('contracts.account', '=', $account)->where('rates.utility', '=', $utility)->max('rates.end_date'); if ($end_date > $today) { return false; } else { return true; } }); }
/** * Store a newly created resource in storage. * * @return Response */ public function postContract(CreateContractRequest $request) { $input = Cookie::get('rate'); $email = $request->input('email'); $name = $request->input('first_name'); $rate = Rate::find($input); $contract = new Contract($request->all()); $contract->rate()->associate($rate); /* $contract->save(); */ /* mail('*****@*****.**','Test','Hello,','') */ /* email contract */ /** Mail::send('emails.contract', $data, function ($message) * { * $message->from('*****@*****.**', 'Laravel'); * $message->to('*****@*****.**'); * $message->subject($subject); * $message->attach($pathToFile); * }); */ return view('contracts.send')->with('email', $email); }
public function rating($id, $user_id) { $rate = Input::get('rate'); Rate::create(['user_id' => $user_id, 'product_id' => $id, 'rate' => $rate]); }
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'); }
/** * Store a newly created resource in storage. * * @param CreateContractRequest $request * @return Response */ public function postContract(CreateContractRequest $request) { //$id = Cookie::get('rate'); //Create contract $id = $request->input('id'); $rate = Rate::find($id); $contract = new Contract($request->all()); $contract->rate()->associate($rate); $contract->save(); // Contract details $email = $request->input('email'); //Create pdf attachement // Simple email /* mail('*****@*****.**','Test','Hello,','') */ /* // Email contract Mail::send('emails.contract', $data, function ($message) { $message->from('*****@*****.**', 'Laravel'); $message->to('*****@*****.**'); $message->subject($subject); $message->attach($pathToFile); }); */ return view('electric.success')->with('email', $email); }
public function gymaccess_update(Request $request) { $customer = customer::find($request->id); $customer->gymaccess_ind = 1; $customer->save(); $gymaccess = new gymaccess(); $gymaccess->customer_id = $request->id; $gymaccess->activation_date = Carbon::today(); $rate_id = $request->gymaccess; $rate = Rate::where('id', '=', $rate_id)->firstOrFail(); /*$price = number_format( $rate->price, 2);*/ if ($rate->period == 'day') { $gymaccess->expiration_date = Carbon::today()->addDays($rate->period_count); } else { if ($rate->period == 'month') { $gymaccess->expiration_date = Carbon::today()->addMonths($rate->period_count)->subDay(); } else { if ($rate->period == 'year') { $gymaccess->expiration_date = Carbon::today()->addYears($rate->period_count)->subDay(); } } } $gymaccess->active_ind = 1; $gymaccess->save(); return redirect('dashboard'); }
/** * Created by Dara on 8/12/2015 * the staration index page */ public function index() { $users = User::with('roles')->paginate(20); $latestRatings = Rate::latest()->first(); return view('admin.staration.index', compact('users', 'latestRatings'))->with(['title' => 'Users Rating']); }
private function makeRate($carmodel, $subcomponent, $repairshop, $amount) { $rate = Rate::firstOrNew(['carmodel_id' => $carmodel->carmodel_id, 'subcomponent_id' => $subcomponent->subcomponent_id, 'repairshop_id' => $repairshop->repairshop_id]); $rate->amount = $amount; $rate->carmodel()->associate($carmodel); $rate->subcomponent()->associate($subcomponent); $rate->repairshop()->associate($repairshop); $rate->save(); return $rate; }
/** * Run the database seeds. * * @return void */ public function run() { Rate::create(['parentable_id' => '', 'parentable_type' => '', 'rate' => 1]); }