コード例 #1
0
ファイル: RateController.php プロジェクト: makgyber/herb
 /**
  * Store a newly created Rate in storage.
  *
  * @param CreateRateRequest $request
  *
  * @return Response
  */
 public function store(CreateRateRequest $request)
 {
     $input = $request->all();
     $rate = $this->rateRepository->create($input);
     Flash::success('Rate saved successfully.');
     return redirect(route('rates.index'));
 }
コード例 #2
0
ファイル: RatesController.php プロジェクト: evanlerch/caravan
 /**
  *
  *
  * @return Response
  */
 public function getRates(CreateRateRequest $request)
 {
     $zip_code = $request->input('zip_code');
     $utility = $request->input('utility');
     $rate_class = $request->input('rate_class');
     $rawUsage = $request->input('usage');
     $usage = intval(preg_replace('/[^\\d.]/', '', $rawUsage));
     $rates = Rate::select('id', 'term', 'supplier', 'price')->whereIn('price', function ($q) use($zip_code, $utility, $rate_class, $usage) {
         $q->from('rates')->selectRaw('min(price)')->where('zip_code', '=', $zip_code)->where('utility', '=', $utility)->where('rate_class', '=', $rate_class)->where('min_usage', '<=', $usage)->where('max_usage', '>=', $usage)->groupBy('term');
     })->orderBy('term', 'asc')->get();
     return view('rates.index', compact('rates'));
 }