Пример #1
0
 /**
  * Add new restaurants data
  *
  * @param $data
  * @return RestaurantsCms|\Illuminate\Support\Collection|null|static
  * @throws \Exception
  */
 public function addRestaurant($data)
 {
     try {
         $restaurant = $this->find($data['id']);
         if (!$restaurant) {
             $restaurant = new RestaurantsCms();
             $restaurant->id = $data['id'];
             $restaurant->rating = 0;
             $restaurant->view_count = 0;
             $restaurant->status_close = 0;
             $restaurant->status_verify = 1;
         }
         $restaurant->name = $data['name'];
         $restaurant->slug_name = '';
         $restaurant->address = $data['address'];
         $restaurant->telephone = $data['telephone'];
         $restaurant->budget = $data['budget'];
         $restaurant->operating_time = $data['operating_time'];
         $restaurant->latitude = $data['latitude'];
         $restaurant->longitude = $data['longitude'];
         $restaurant->thumbnail = $data['thumbnail'];
         $restaurant->credit_card = $data['credit_card'];
         $restaurant->smoking = !empty($data['smoking']) ? $data['smoking'] : 0;
         $restaurant->is_24hours = !empty($data['is_24hours']) ? $data['is_24hours'] : 0;
         $restaurant->can_dinein = !empty($data['can_dinein']) ? $data['can_dinein'] : 1;
         $restaurant->can_dineout = !empty($data['can_dineout']) ? $data['can_dineout'] : 1;
         $restaurant->can_deliver = !empty($data['can_deliver']) ? $data['can_deliver'] : 0;
         $restaurant->user_id = !empty($data['user_id']) ? $data['user_id'] : 0;
         $restaurant->save();
         return $restaurant;
     } catch (\Exception $e) {
         throw $e;
     }
 }
Пример #2
0
 /**
  * Return the details of the reported restaurant
  * Used for the View popup
  *
  * @param $restaurant_id
  * @return View
  */
 public function viewRestaurantAction($restaurant_id)
 {
     $data = array();
     $restaurant = RestaurantsCms::find($restaurant_id)->toArray();
     if ($restaurant) {
         $boolean_columns = array('can_deliver', 'can_dinein', 'can_dineout', 'is_24hours', 'smoking', 'credit_card', 'status_close');
         foreach ($restaurant as $key => $value) {
             if (in_array($key, $boolean_columns)) {
                 if ($value === CONSTANTS::YES) {
                     $restaurant[$key] = 'Yes';
                 } elseif ($value === CONSTANTS::NO) {
                     $restaurant[$key] = 'No';
                 }
             }
             if ($key == 'status_verify') {
                 if ($value === CONSTANTS::STATUS_ACTIVE) {
                     $restaurant[$key] = 'Active';
                 } else {
                     $restaurant[$key] = 'Inactive';
                 }
             }
         }
         $data['restaurant'] = $restaurant;
     }
     return view('cms.reported.restaurants.view', $data);
 }
Пример #3
0
 /**
  * Approve suggested restaurant
  *
  * @param Request $request
  * @return \Illuminate\View\View
  */
 public function approveSuggestedAction(Request $request)
 {
     DB::transaction(function () use($request) {
         $id = $request->input('id');
         $suggested_restaurant = RestaurantsSuggest::find($id);
         $suggested_restaurant->status_verify = CONSTANTS::STATUS_APPROVED;
         $suggested_restaurant->save();
         // Set the restaurant_id with initial value (90,000)
         $restaurant_id = CONSTANTS::SUGGESTED_RESTAURANT_INITIAL_ID;
         $restaurant_max_id = Restaurants::max('id');
         if ($restaurant_id <= $restaurant_max_id) {
             $restaurant_id = ++$restaurant_max_id;
         }
         $suggested_restaurant->id = $restaurant_id;
         $restaurant_cms = new RestaurantsCms();
         $restaurant_cms->addRestaurant($suggested_restaurant);
         $cuisines = explode(', ', $suggested_restaurant->cuisines);
         foreach ($cuisines as $cuisine) {
             $categoriesCms = CategoriesCms::where('name', $cuisine)->first();
             if ($categoriesCms) {
                 $restaurant_category = RestaurantsCategoryCms::getByRestaurantCatId($restaurant_id, $categoriesCms['id']);
             }
             if (!$restaurant_category) {
                 $restaurant_category = new RestaurantsCategoryCms();
                 $restaurant_category->addRestaurantCategory($restaurant_id, $categoriesCms['id']);
             }
         }
         $restaurant_cms->updateRestaurantSlugName();
     });
     return redirect('cms/restaurant/suggested/index')->with('success', 'Successfully added new restaurant!');
 }