예제 #1
0
 /**
  *
  *
  * @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'));
 }
예제 #2
0
 /**
  * Return contract form.
  * 
  * @return Response
  */
 public function getContractForm($zip_code, $id)
 {
     //$id    = $id;
     //$cookie = Cookie::queue('rate', $id, 60);
     $rates = Rate::select('id', 'term', 'supplier', 'price', 'state', 'rate_class_group')->where('id', '=', $id)->get();
     $utility_name = Utility::select('utilities.name')->join('rates', 'utilities.utility', '=', 'rates.utility')->where('rates.id', '=', $id)->pluck('name');
     //return view('electric.contract', compact('rates'))->withCookie($cookie)->with('zip_code', $zip_code)->with('id', $id)->with('utility_name', $utility_name);
     return view('electric.contract', compact('rates'))->with('zip_code', $zip_code)->with('id', $id)->with('utility_name', $utility_name);
 }
예제 #3
0
파일: Rate.php 프로젝트: evanlerch/caravan
 /**
  * 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;
 }
예제 #4
0
 /**
  * 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;
         }
     });
 }
예제 #5
0
 public function getRates()
 {
     $rates = Rate::select('id', 'supplier', 'state', 'start_date', 'end_date', 'rate_class', 'rate_class_group', 'load_zone', 'term', 'price', 'utility', 'min_usage', 'max_usage')->where('state', '=', 'MA')->orderBy('created_at', 'asc')->get();
     return view('admin.rates', compact('rates'));
 }