/**
  * Upload avatar to Cloudinary and save the returned url to database
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function updateAvatar(Request $request)
 {
     if ($request['file']) {
         $result = Uploader::upload($request['file'], ["public_id" => Auth::user()->username . rand(1, 100)]);
         $profile = Profile::where('user_id', Auth::user()->id)->first();
         $profile->avatar = $result['url'];
         $profile->save();
     }
     return redirect('dashboard');
 }
Exemplo n.º 2
0
 /**
  * Create profile for a new user authenticated through a social provider
  *
  * @param $userData
  * @param $user_id
  */
 protected function createUserProfile($userData, $user_id)
 {
     Profile::create(['user_id' => $user_id, 'first_name' => isset($userData->user['first_name']) ? $userData->user['first_name'] : NULL, 'last_name' => isset($userData->user['last_name']) ? $userData->user['last_name'] : NULL, 'avatar' => isset($userData->avatar_original) ? $userData->avatar_original : $userData->avatar]);
 }