Ejemplo n.º 1
0
 /**
  * Store a newly created profile in storage.
  *
  * @return Response
  */
 public function store(CreateProfileRequest $request)
 {
     $profile = Profile::firstOrNew(['user_id' => \Auth::id()]);
     if ($request->id) {
         $placeliving = Place::where('id', '=', $request->id)->first();
         if (!$placeliving) {
             $placeliving = new Place($request->only(['id', 'place_lat', 'place_lng', 'country', 'state', 'city']));
             $placeliving->save();
         }
         $profile->place_living_id = $request->id;
     }
     if ($request->id2) {
         $placefrom = Place::where('id', '=', $request->id2)->first();
         if (!$placefrom) {
             $placefrom = new Place();
             $placefrom->id = $request->id2;
             $placefrom->place_lat = $request->place_lat2;
             $placefrom->place_lng = $request->place_lng2;
             $placefrom->country = $request->country2;
             $placefrom->state = $request->state2;
             $placefrom->city = $request->city2;
             $placefrom->save();
         }
         $profile->place_from_id = $request->id2;
     }
     if ($request->about) {
         $profile->about = $request->about;
     }
     if ($request->occupation) {
         $profile->occupation = $request->occupation;
     }
     if ($request->studies) {
         $profile->studies = $request->studies;
     }
     if ($request->transport) {
         $profile->transport = $request->transport;
     }
     $profile->save();
     \Session::flash('message', 'Profile updated successfully');
     return redirect()->route('index');
 }
Ejemplo n.º 2
0
 /**
  * @param $reviewData
  * @return \App\Review
  */
 public static function normalize(&$reviewData)
 {
     $review = ReviewModel::firstOrNew(['external_id' => $reviewData['id']]);
     $review->external_id = $reviewData['id'];
     $review->text = $reviewData['text'];
     $review->date = Carbon::createFromTimestamp($reviewData['date']);
     $profileData = $reviewData['profile'];
     $profile = ProfileModel::firstOrNew(['external_id' => $reviewData['profile']['uid']]);
     $profile->first_name = $profileData['first_name'];
     $profile->last_name = $profileData['last_name'];
     $profile->domain = $profileData['domain'];
     if (isset($profileData['photo_200_orig'])) {
         $profile->photo = $profileData['photo_200_orig'];
     }
     if (isset($profileData['photo_400_orig'])) {
         $profile->photo_big = $profileData['photo_400_orig'];
     }
     $profile->save();
     $profile->reviews()->save($review);
     return $review;
 }