Beispiel #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $restaurant = new Restaurant();
     $restaurant->name = $request->input('name');
     $restaurant->address = $request->input('address');
     $restaurant->phone = $request->input('phone');
     $restaurant->img = $request->input('img');
     $restaurant->save();
     return 'Restaurant record successfully created with id ' . $restaurant->id_restaurant;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request, $orgId)
 {
     $restaurant = new \App\Restaurant();
     $restaurant->fill($request->input('Restaurant', []));
     if ($restaurant->isValid()) {
         $restaurant->save();
         return redirect()->route('restaurant.index', ['orgId' => $orgId]);
     } else {
         return redirect()->route('restaurant.create')->withErrors($restaurant->getErrors())->withInput();
     }
 }
Beispiel #3
0
 function addRestaurant(Request $request)
 {
     $current_user = Session::get('user');
     if (!isset($current_user)) {
         return 'you must login first.';
     } else {
         $id_tmp = 0;
         if (($count = Item::count()) != 0) {
             $id_tmp = Item::skip($count - 1)->first()->item_id;
         }
         $id_tmp = $id_tmp + 1;
         $item = new Item();
         $restaurant = new Restaurant();
         $location = new Location();
         $photo = new PhotoGallery();
         /*---------------------upload_picture-----------------------*/
         $file = Input::file('profile_picture');
         if ($file != null) {
             $destinationPath = 'img/';
             $filename = md5(microtime() . $file->getClientOriginalName()) . "." . $file->getClientOriginalExtension();
             Input::file('profile_picture')->move($destinationPath, $filename);
             $num_photo = DB::table('photo_gallery')->count();
             $photo->photo_id = DB::table('photo_gallery')->skip($num_photo - 1)->first()->photo_id + 1;
             $photo->link_item_id = $id_tmp;
             $photo->photo_url = '/' . $destinationPath . $filename;
             $item->title_picture = $photo->photo_url;
             $photo->save();
         }
         /*---------------------------------------------------------*/
         $item->item_id = $id_tmp;
         $item->title = $request->in_new_title;
         $item->description = $request->in_new_description;
         $item->tel = $request->in_new_tel;
         $item->user_id = $current_user[5];
         if ($current_user[4] == "Admin") {
             $item->isApproved = 1;
         } else {
             $item->isApproved = 0;
         }
         $restaurant->price_range = $request->in_new_price_range;
         $restaurant->food_type = $request->in_new_food_type;
         $restaurant->oc_time = $request->in_new_oc_time;
         $restaurant->credit_card = $request->in_new_credit_card;
         $restaurant->child_appropriate = $request->in_new_child_appropriate;
         $restaurant->reservable = $request->in_new_reservable;
         $restaurant->parking = $request->in_new_parking;
         $restaurant->link_item_id = $id_tmp;
         $location->hint = $request->in_new_hint;
         $location->build = $request->in_new_build;
         $location->sub_district = $request->in_new_sub_dis;
         $location->district = $request->in_new_district;
         $location->province = $request->in_new_province;
         $location->postal_code = $request->in_new_post_code;
         $location->lat = $request->in_new_lat;
         $location->long = $request->in_new_lng;
         $location->link_item_id = $id_tmp;
         $item->save();
         $location->save();
         $restaurant->save();
         return redirect('/page_restaurant/info/' . $id_tmp);
     }
 }