Example #1
0
 public function findOrCreateUser($githubUser)
 {
     if ($authUser = User::where('github_id', $githubUser->id)->first()) {
         return $authUser;
     }
     return User::create(['github_id' => $githubUser->id, 'name' => $githubUser->name, 'nickname' => $githubUser->nickname, 'email' => $githubUser->email, 'avatar' => $githubUser->avatar]);
 }
Example #2
0
 public function profile($name)
 {
     $user = User::where('name', $name)->with(['posts' => function ($q) {
         $q->orderBy('created_at', 'desc');
     }])->first();
     if (Request::wantsJson()) {
         $user->clickSum = Post::where('user_id', $user->id)->sum('clickNum');
         $user->approveSum = DB::table('approves')->sum('user_id');
         return response()->json($user, 200);
     }
     return view('user.profile', compact('user'));
 }
Example #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::create(['github_id' => 11711621, 'name' => 'RryLee', 'nickname' => 'RryLee', 'avatar' => 'https://avatars.githubusercontent.com/u/11711621?v=3', 'email' => '*****@*****.**', 'home' => 'https://github.com/RryLee']);
 }