/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $this->view_data['rental_services'] = RentalService::active()->get();
     $this->view_data['purchase_services'] = PurchaseService::active()->get();
     $this->view_data['costs'] = Config::get('constants.costs');
     return view($this->view_data['view_path_root'] . '.index', $this->view_data);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $input = $request->all();
     $res['status'] = 400;
     $res['message'] = '';
     $res['errors'] = [];
     $rental_services = RentalService::active()->get();
     $purchase_services = PurchaseService::active()->get();
     $data['costs'] = Config::get('constants.costs');
     $data['rental_services'] = [];
     foreach ($rental_services as $rental_service) {
         if (!isset($input[$rental_service->id . '___rental'])) {
             $res['message'] = 'An error occour, please refresh page and try again.';
             return response()->json($res);
         }
         $data['rental_services'][$rental_service->id]['title'] = $rental_service->title;
         $data['rental_services'][$rental_service->id]['quantity'] = (int) $input[$rental_service->id . '___rental'];
         $data['rental_services'][$rental_service->id]['unit_price'] = (double) $rental_service->price;
         $data['rental_services'][$rental_service->id]['price'] = $data['rental_services'][$rental_service->id]['quantity'] * $data['rental_services'][$rental_service->id]['unit_price'];
     }
     // $data['purchase_services'] = [];
     // foreach ($purchase_services as $purchase_service) {
     // 	if(!isset($input[$purchase_service->id.'___purchase'])){
     // 		$res['message'] = 'An error occour, please refresh page and try again.';
     // 		return response()->json($res);
     // 	}
     // 	$data['purchase_services'][$purchase_service->id]['title'] = $purchase_service->title;
     // 	$data['purchase_services'][$purchase_service->id]['quantity'] = (int) $input[$purchase_service->id.'___purchase'];
     // 	$data['purchase_services'][$purchase_service->id]['unit_price'] = (float) $purchase_service->price;
     // 	$data['purchase_services'][$purchase_service->id]['price'] = $data['purchase_services'][$purchase_service->id]['quantity'] * $data['purchase_services'][$purchase_service->id]['unit_price'];
     // }
     $data['delievery_info'] = [];
     $data['delievery_info']['preferred_delivery_address'] = $input['preferred_delivery_address'];
     $data['delievery_info']['building_name'] = $input['building_name'];
     $data['delievery_info']['room_no'] = $input['room_no'];
     $data['delievery_info']['phone_no'] = $input['phone_no'];
     $data['bank_details'] = [];
     $data['bank_details']['bank_name'] = $input['bank_name'];
     $data['bank_details']['account_no'] = $input['account_no'];
     $data['bank_details']['reveiver_name'] = $input['reveiver_name'];
     $res['data'] = $data;
     $res['status'] = 200;
     return response()->json($res);
 }