/**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(RegisterRequest $request)
 {
     $user = User::create($request->all());
     Auth::login($user);
     return redirect('home')->withSuccessMessage('Thank you for signing up!');
     // when creating a user we also need to add a dummy aavatar by default
 }
Example #2
0
 /**
  * Show a single post of a user with comments
  * @param  [type] $employeeId [description]
  * @param  [type] $postid     [description]
  * @return [type]             [description]
  */
 public function show($employeeId, $postid, PostComments $postComments)
 {
     $user = User::with('aavatar')->findByEmployeeId($employeeId);
     $post = $user->posts()->findOrFail($postid);
     $comments = $postComments->commentFor($post)->simplePaginate();
     return view('posts.show', compact('post', 'user', 'comments'));
 }
Example #3
0
 /**
  * Show a Users Profile & Posts
  * @param   $employeeId
  * @return  View
  */
 public function show($employeeId)
 {
     $user = User::findByEmployeeId($employeeId);
     $feeds = DB::table('posts')->select(DB::raw('posts.body, posts.created_at,posts.id AS post_id,
                   images.caption AS image_caption, images.path AS image_path, images.thumbnail_path,
                   COUNT( DISTINCT( comments.id ) ) AS comment_count, COUNT( DISTINCT(likes.id ) ) AS like_count,
                   users.name AS user_name, users.employee_id, users.id as user_id'))->join('users', 'users.id', '=', 'posts.user_id')->join('images', 'posts.user_id', '=', 'images.user_id')->leftJoin('comments', 'comments.post_id', '=', 'posts.id')->leftJoin('likes', function ($join) {
         $join->on('likes.likeable_id', '=', 'posts.id')->where('likes.likeable_type', ' = ', 'Banijya\\Post');
     })->where('posts.user_id', '=', $user->id)->groupBy('posts.id')->latest('posts.created_at')->simplePaginate();
     return view('users.show')->with(compact('user', 'feeds'));
 }
Example #4
0
 /**
  * Send a friend request to other users
  * @param   $userId
  * @param    $auth
  * @return   redirect
  */
 public function sendRequest($userId, Guard $auth)
 {
     $user = User::findOrFail($userId);
     if ($auth->user()->isFriendsWith($user)) {
         // if already friends no point on going further
         return redirect()->route('home')->withSuccessMessage('You are already friends.');
     }
     if ($auth->user()->hasFriendRequestPending($user) || $user->hasFriendRequestPending($auth->user())) {
         return redirect()->route('home')->withSuccessMessage('Friend Request already pending.');
     }
     $auth->user()->addFriend($user);
     return redirect(URL::previous() . "#friend-{$user->employee_id}")->withSuccessMessage("Friend request sent to {$user->name}");
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     User::created(function ($user) {
         $user->aavatar()->create([]);
     });
 }
Example #6
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }