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();
     });
 }
 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');
 }
示例#4
0
 /**
  * @param $repairshops
  * @param $subcomponent
  * @param $region
  * @param $regionModel
  * @return array
  */
 private function returnAnalysis($repairshops, $subcomponent, $region, $regionModel)
 {
     $results = false;
     $sub = SubComponent::findOrFail($subcomponent);
     if (!$repairshops->isEmpty()) {
         $rates = array();
         foreach ($repairshops as $repairshop) {
             $whereParams = ['subcomponent_id' => $subcomponent, 'repairshop_id' => $repairshop->repairshop_id];
             $query = Rate::where($whereParams)->orderBy('carmodel_id', 'asc')->get();
             if (!$query->isEmpty()) {
                 foreach ($query as $rate) {
                     $rates[] = $rate;
                 }
             }
         }
         if (empty($rates)) {
             return ['results' => $results, 'subcomponent' => $sub, 'region' => $region, 'regionModel' => $regionModel];
         }
         $minmax = $this->findMinMax($rates);
         $results = true;
         return array('results' => $results, 'analytics' => $minmax, 'rates' => $rates, 'subcomponent' => $sub, 'region' => $region, 'regionModel' => $regionModel);
     } else {
         return ['results' => $results, 'subcomponent' => $sub, 'region' => $region, 'regionModel' => $regionModel];
     }
 }