コード例 #1
0
 private function addNormalUser($aRequest)
 {
     $aUser = array();
     foreach ($this->aUserParams as $sParam) {
         switch ($sParam) {
             case "username":
                 $aUser[$sParam] = strtolower($aRequest[$sParam]);
                 break;
             case "logo":
                 $aUser['photo'] = Backend::uploadPhotos($aRequest['logo'], 'logo');
                 break;
             default:
                 $aUser[$sParam] = $aRequest[$sParam];
                 break;
         }
     }
     $aUser['date_registered'] = date('Y-m-d h:i:s');
     $aUser['age'] = $aRequest['date_of_birth'];
     $aUser['user_mobile'] = $aRequest['telephone'];
     $aUser['user_status'] = 'active';
     unset($aUser['date_of_birth']);
     unset($aUser['telephone']);
     //Hashing the password to be saved encrypted
     $aUser['password'] = Hash::make($aUser['password']);
     DB::table('users')->insert($aUser);
     $dIdUser = DB::table('users')->where(array('username' => $aUser['username']))->get(array('id_user'));
     DB::table('user_rating')->insert(array('id_user' => $dIdUser[0]->id_user, 'likes_count' => 0));
     echo "You've registered successfully!";
     return redirect()->intended('/');
 }
コード例 #2
0
 public function submitReview()
 {
     //Get the request from the submitted page
     $aRequest = \Request::all();
     //Get the Session
     $aSession = \Session::all();
     //GET RESTAURANT ID
     $aRestaurant = DB::table('restaurants')->where(array('username' => $aRequest['username']))->get(array("id_restaurant"));
     $oRestaurant = $aRestaurant[0];
     $aReview['id_restaurant'] = $oRestaurant->id_restaurant;
     $aReview['id_user'] = $aSession['id_user'];
     $aReview['body'] = $aRequest['review'];
     $aReview['rating'] = $aRequest['rating'];
     $oImage = $aRequest['review-picture'];
     //Uplaod the pociture of the review
     $FullImagePath = Backend::uploadPhotos($oImage, 'review-picture');
     $aReview['review_image'] = $FullImagePath;
     $aReview['date_created'] = Date('Y-m-d h:i:s');
     //Insert the data into Reviews Table and get it's id
     $dReviewId = DB::table('reviews')->insertGetId($aReview);
     //Add Activity to it's table
     //save activity into the DB:
     Backend::addActivity($aSession['id_user'], 'review', $dReviewId);
     //Redirect the user to the restaurant's page.
     return redirect('/p/' . $aRequest['username']);
 }