/**
  * Gets homepage
  */
 public function getHome()
 {
     $users = User::all();
     $videos = Video::all();
     $categories = Category::with('videosCount')->get();
     return view('home', compact('users', 'videos', 'categories'));
 }
Example #2
0
 /**
  * checks if user exists then creates new if user does not exist
  */
 private function findOrCreateUser($theUser, $provider)
 {
     $authUser = User::where('uid', $theUser->id)->first();
     $username = isset($theUser->user['first_name']) ? $theUser->user['first_name'] : $theUser->nickname;
     if ($authUser) {
         return $authUser;
     }
     if (User::where('username', $theUser->nickname)->first()) {
         $user = factory(User::class)->make(['username' => $username, 'email' => $theUser->email, 'provider' => $provider, 'uid' => $theUser->id, 'avatar_url' => $theUser->avatar]);
     }
     return User::create(['username' => $username, 'email' => $theUser->email, 'provider' => $provider, 'uid' => $theUser->id, 'avatar_url' => $theUser->avatar]);
 }
 /**
  * Updates user's avatar
  */
 public function updateAvatar(Request $request)
 {
     $img = Input::file('avatar_url');
     User::find(Auth::user()->id)->updateAvatar($this->getImageUrl($img));
     return Redirect::back()->with('status', 'Avatar updated successfully.');
 }