/**
  * Execute the command.
  *
  * @param RestaurantLocationsRepository $repository
  * @param VendorLocation $vendorLocation
  * @return array
  */
 public function handle(RestaurantLocationsRepository $repository, VendorLocation $vendorLocation)
 {
     $restaurantLocation = $vendorLocation->add($this->vendor_id, $this->location_id, $this->title, $this->slug, $this->status, $this->short_description, $this->description, $this->seo_title, $this->seo_meta_description, $this->seo_meta_keywords, $this->main_image, $this->listing_image, $this->gallery_images, $this->min_people_per_reservation, $this->max_people_per_reservation, $this->max_reservation_per_time_slot, $this->max_reservation_per_day, $this->min_reservation_time_buffer, $this->max_reservation_time_buffer, $this->schedules, $this->allow_alacarte_reservation, $this->alacarte_terms_conditions, $this->address, $this->city, $this->state, $this->country, $this->pin_code, $this->latitude, $this->longitude, $this->driving_locations, $this->location_map, $this->cuisine, $this->collections, $this->commision_per_reservation, $this->prepayment, $this->reward_points_per_reservation, $this->publish_date, $this->publish_time);
     $response = $repository->add($restaurantLocation);
     //event(new NewUserWasRegistered($this->email,$this->full_name));
     return $response;
 }
Example #2
0
 public function login()
 {
     try {
         $passwordMatch = false;
         $userDeviceUpdated = false;
         $access_token = '';
         $input = Request::all();
         $user = User::where('email', $input['email'])->first();
         if ($user) {
             if (crypt($input['password'], $user->password) == $user->password) {
                 $passwordMatch = true;
             }
         }
         if ($passwordMatch) {
             $userDevice = UserDevice::where('device_id', $input['device_id'])->first();
             $access_token = Uuid::uuid1()->toString();
             if ($userDevice) {
                 $userDeviceUpdated = $userDevice->update(['device_id' => $input['device_id'], 'rest_access_token' => $access_token, 'rest_access_token_expires' => Carbon::now()->addDays(360), 'rest_notification_id' => $input['notification_id'], 'os_type' => $input['os_type'], 'os_version' => $input['os_version'], 'hardware' => $input['hardware'], 'rest_app_version' => $input['app_version'], 'user_id' => $user->id]);
             } else {
                 $userDeviceUpdated = UserDevice::create(['device_id' => $input['device_id'], 'rest_access_token' => $access_token, 'rest_access_token_expires' => Carbon::now()->addDays(360), 'rest_notification_id' => $input['notification_id'], 'os_type' => $input['os_type'], 'os_version' => $input['os_version'], 'hardware' => $input['hardware'], 'rest_app_version' => $input['app_version'], 'user_id' => $user->id]);
             }
         }
         if ($userDeviceUpdated) {
             $vendorLocationContact = VendorLocationContact::where('user_id', $user->id)->first();
             $vendorLocation = VendorLocation::where('id', $vendorLocationContact->vendor_location_id)->first();
             $vendor = Vendor::where('id', $vendorLocation->vendor_id)->first();
             return response()->json(['id' => $user->id, 'access_token' => $access_token, 'full_name' => $user->full_name, 'email' => $user->email, 'phone_number' => $user->phone_number, 'role' => $user->role->name, 'vendor_name' => $vendor->name], 200);
         } else {
             return response()->json(['action' => 'Check if the email address and password match', 'message' => 'There is an email password mismatch. Please check and try again'], 227);
         }
     } catch (\Exception $e) {
         return response()->json(['message' => 'An application error occured.', 'error' => $e->getMessage()], 500);
     }
 }
Example #3
0
 public function compose(View $view)
 {
     $view->with('uri', $this->request->path());
     $view->with('currentUser', $this->user);
     $view->with('roles_list', Role::lists('name', 'id'));
     $view->with('user_attributes_list', UserAttributes::lists('name', 'alias'));
     $view->with('restaurant_attributes_list', VendorAttributes::lists('name', 'alias'));
     $view->with('restaurant_locations_list', VendorLocation::wherehas('vendor.vendorType', function ($q) {
         $q->where('type', 'Restaurants');
     })->lists('slug', 'id'));
     $view->with('cities_list', Location::where('Type', 'City')->lists('name', 'id'));
     $view->with('locations_area_list', Location::where('Type', 'Area')->lists('name', 'id'));
     $view->with('cuisines', VendorAttributesSelectOptions::wherehas('attribute', function ($q) {
         $q->where('alias', 'cuisines');
     })->lists('option', 'id'));
     $view->with('_token', $this->encrypter->encrypt(csrf_token()));
     $view->with('media_url', Config::get('media.base_s3_url'));
     $view->with('curator_list', Curator::lists('name', 'id'));
     $view->with('tags_list', Collection::lists('name', 'id'));
     $view->with('flags_list', Flag::lists('name', 'id'));
     $view->with('restaurants_list', DB::table('vendors')->lists('name', 'id'));
     $experienceTypeArray = array('simple', 'complex');
     $view->with('experiences_list', DB::table('products')->whereIn('type', $experienceTypeArray)->lists('name', 'id'));
     $view->with('locations_list', Location::where('Type', 'Locality')->lists('name', 'id'));
     $view->with('price_type_list', PriceType::lists('type_name', 'id'));
     $variant_lists = DB::table('product_variant_options')->lists('variation_name', 'id');
     $view->with('variant_list', $variant_lists);
     $complex_experience_list = DB::table('products')->where('type', "complex")->lists('name', 'id');
     $view->with('complex_experience_list', $complex_experience_list);
     $curators_list = Curator::all()->lists('name', 'id');
     $curatorsList = [];
     foreach ($curators_list as $key => $value) {
         $curatorsList[] = ['id' => $key, 'text' => $value];
     }
     $flags_list = Flag::all()->lists('name', 'id');
     $flagsList = [];
     foreach ($flags_list as $key => $value) {
         $flagsList[] = ['id' => $key, 'text' => $value];
     }
     $restaurants_list = DB::table('vendors')->lists('name', 'id');
     $restaurantsList = [];
     foreach ($restaurants_list as $key => $value) {
         $restaurantsList[] = ['id' => $key, 'text' => $value];
     }
     $localities_list = Location::where('Type', 'Locality')->lists('name', 'id');
     $localitiesList = [];
     foreach ($localities_list as $key => $value) {
         $localitiesList[] = ['id' => $key, 'text' => $value];
     }
     //echo "test".die;
     JavaScript::put(['curatorsList' => $curatorsList, 'flagsList' => $flagsList, 'restaurantsList' => $restaurantsList, 'localitiesList' => $localitiesList]);
 }
 public function add(VendorLocation $vendorLocation)
 {
     $vendorLocation->save();
 }
Example #5
0
 /**
  * Returns all the location of a Vendor matching
  * the passed id.
  * 
  * @static	true
  * @access	public
  * @param	integer	$vendorID
  * @return	array
  * @since	v1.0.0
  */
 public static function getVendorLocation($vendorID)
 {
     //array to contain the list of locations
     $arrLocation = array();
     foreach (VendorLocation::with('location')->where('vendor_id', '=', $vendorID)->get() as $vendorLocation) {
         $arrLocation[] = array('name' => $vendorLocation->location->name, 'slug' => $vendorLocation->slug);
     }
     return $arrLocation;
 }
 /**
  * Push this reservation to specified devices
  *
  * @param  int  $id
  * @return Response
  */
 public function push($id, $tokenArr, $showNotification)
 {
     try {
         $reservation = array();
         $key = 'reservation_id';
         $value = (int) $id;
         $reservation[$key] = $value;
         //Int type
         $reservationIntAttrArr = ReservationAttributesInteger::where('reservation_id', (int) $id)->get();
         foreach ($reservationIntAttrArr as $reservationIntAttr) {
             $key = $reservationIntAttr->attribute->alias;
             $value = $reservationIntAttr->attribute_value;
             $reservation[$key] = $value;
             //Check log for same attribute
             $reservationStatusLog = ReservationStatusLog::where(['reservation_id' => $reservationIntAttr->reservation_id, 'new_reservation_status_id' => ReservationController::$edited_status_id])->orderBy('created_at', 'DESC')->first();
             if ($reservationStatusLog != null) {
                 $reservationIntAttrLogArr = ReservationAttributesIntegerLog::where(['reservation_attribute_id' => $reservationIntAttr->attribute->id, 'reservation_status_log_id' => $reservationStatusLog->id])->get();
                 foreach ($reservationIntAttrLogArr as $reservationIntAttrLog) {
                     $key = "old_" . $reservationIntAttrLog->attribute->alias;
                     $value = $reservationIntAttrLog->old_attribute_value;
                     $reservation[$key] = $value;
                 }
             }
         }
         //Float type
         $reservationFloatAttrArr = ReservationAttributesFloat::where('reservation_id', (int) $id)->get();
         foreach ($reservationFloatAttrArr as $reservationFloatAttr) {
             $key = $reservationFloatAttr->attribute->alias;
             $value = $reservationFloatAttr->attribute_value;
             $reservation[$key] = $value;
         }
         //Date type
         $reservationDateAttrArr = ReservationAttributesDate::where('reservation_id', (int) $id)->get();
         foreach ($reservationDateAttrArr as $reservationDateAttr) {
             $key = $reservationDateAttr->attribute->alias;
             $value = $reservationDateAttr->attribute_value;
             $reservation[$key] = $value;
             //Check log for same attribute
             $reservationStatusLog = ReservationStatusLog::where(['reservation_id' => $reservationDateAttr->reservation_id, 'new_reservation_status_id' => ReservationController::$edited_status_id])->orderBy('created_at', 'DESC')->first();
             if ($reservationStatusLog != null) {
                 $reservationDateAttrLogArr = ReservationAttributesDateLog::where(['reservation_attribute_id' => $reservationDateAttr->attribute->id, 'reservation_status_log_id' => $reservationStatusLog->id])->get();
                 foreach ($reservationDateAttrLogArr as $reservationDateAttrLog) {
                     $key = "old_" . $reservationDateAttrLog->attribute->alias;
                     $value = $reservationDateAttrLog->old_attribute_value;
                     $reservation[$key] = $value;
                 }
             }
         }
         //Text type
         $reservationTextAttrArr = ReservationAttributesText::where('reservation_id', (int) $id)->get();
         foreach ($reservationTextAttrArr as $reservationTextAttr) {
             $key = $reservationTextAttr->attribute->alias;
             $value = $reservationTextAttr->attribute_value;
             $reservation[$key] = $value;
             $reservationStatusLog = ReservationStatusLog::where(['reservation_id' => $reservationTextAttr->reservation_id, 'new_reservation_status_id' => ReservationController::$edited_status_id])->orderBy('created_at', 'DESC')->first();
             if ($reservationStatusLog != null) {
                 $reservationTextAttrLogArr = ReservationAttributesTextLog::where(['reservation_attribute_id' => $reservationTextAttr->attribute->id, 'reservation_status_log_id' => $reservationStatusLog->id])->get();
                 foreach ($reservationTextAttrLogArr as $reservationTextAttrLog) {
                     $key = "old_" . $reservationTextAttrLog->attribute->alias;
                     $value = $reservationTextAttrLog->old_attribute_value;
                     $reservation[$key] = $value;
                 }
             }
         }
         //Boolean type
         $reservationBoolAttrArr = ReservationAttributesBoolean::where('reservation_id', (int) $id)->get();
         foreach ($reservationBoolAttrArr as $reservationBoolAttr) {
             $key = $reservationBoolAttr->attribute->alias;
             $value = $reservationBoolAttr->attribute_value;
             if ($value == 1) {
                 $reservation[$key] = true;
             } else {
                 $reservation[$key] = false;
             }
         }
         //VarChar type
         $reservationVarcharAttrArr = ReservationAttributesVarchar::where('reservation_id', (int) $id)->get();
         foreach ($reservationVarcharAttrArr as $reservationVarcharAttr) {
             $key = $reservationVarcharAttr->attribute->alias;
             $value = $reservationVarcharAttr->attribute_value;
             $reservation[$key] = $value;
         }
         //Get Customer
         $reservationDetail = ReservationDetail::where('id', (int) $id)->first();
         if ($reservationDetail) {
             $reservation['reservation_type'] = $reservationDetail->reservation_type;
             $customer = array();
             $customer['id'] = $reservationDetail->user->id;
             $customer['full_name'] = $reservationDetail->user->full_name;
             $customer['email'] = $reservationDetail->user->email;
             $customer['phone_number'] = $reservationDetail->user->phone_number;
             $customer['points_earned'] = $reservationDetail->user->points_earned;
             $customer['rating'] = UserRating::where(['user_id' => $reservationDetail->user, 'id' => $reservationDetail->id])->avg('rating');
             if ($customer['rating'] == null) {
                 $customer['rating'] = 0.0;
             }
             $customerPreferences = UserAttributesVarChar::where(['user_id' => $reservationDetail->user->id, 'user_attribute_id' => ReservationController::$cust_pref_attr_id])->first();
             if ($customerPreferences) {
                 $customer['customer_preferences'] = $customerPreferences->attribute_value;
             }
             $reservation['customer'] = $customer;
         }
         //Get Location
         $reservationDetail = ReservationDetail::where('id', (int) $id)->first();
         if ($reservationDetail) {
             $location = array();
             $vendorLocation = VendorLocation::where('id', $reservationDetail->vendor_location_id)->first();
             $location['location_id'] = $vendorLocation->location_id;
             $location['location'] = Location::where('id', $vendorLocation->location_id)->first()->name;
             $reservation['location'] = $location;
         }
         //Get Product
         $reservationDetail = ReservationDetail::where('id', (int) $id)->first();
         if ($reservationDetail && $reservationDetail->reservation_type == 'experience') {
             $product = array();
             $product['product_id'] = $reservationDetail->product_id;
             $product['product'] = Product::where('id', $reservationDetail->product_id)->first()->name;
             $addonsArr = Product::where('product_parent_id', $reservationDetail->product_id)->get();
             if (sizeof($addonsArr) > 0) {
                 $productAddonArr = array();
                 foreach ($addonsArr as $addon) {
                     $addons = array();
                     $addons['addon_id'] = $addon->id;
                     $addons['addon_name'] = $addon->name;
                     $reservationAddonDetail = ReservationAddonsVariantsDetail::where(['reservation_id' => (int) $id, 'reservation_status_id' => $reservation['reservation_status_id'], 'options_id' => $addon->id])->first();
                     if ($reservationAddonDetail != null) {
                         $addons['no_of_persons'] = $reservationAddonDetail->no_of_persons;
                     }
                     array_push($productAddonArr, $addons);
                 }
                 $product['addons'] = $productAddonArr;
             }
             $reservation['product'] = $product;
         }
         if ($showNotification) {
             $reservation["show_notfn"] = 1;
         } else {
             $reservation["show_notfn"] = 0;
         }
         //$tokenArr = json_decode($input['tokens'], true);
         foreach ($tokenArr as $token) {
             PushNotification::app('appNameAndroid')->to($token['token'])->send(json_encode($reservation));
         }
         $arrResponse['status'] = Config::get('constants.API_SUCCESS');
         return response()->json($arrResponse, 200);
     } catch (\Exception $e) {
         return response()->json(['message' => 'An application error occured.', 'error' => $e->getMessage()], 500);
     }
 }