/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $this->statusForm->validate($request->all()); $status = Status::fromForm($request); User::whoHas(Auth::user()->id)->publishStatus($status); flash()->success(trans('messages.status_title'), trans('messages.status_body')); return back(); }
/** * Confirm a user's email address. * * @param string $token * @return mixed */ public function confirmEmail($token) { User::whereToken($token)->firstOrFail()->confirmEmail(); flash()->overlay(trans('messages.verified_email1'), trans('messages.verified_email2'), 'info'); return redirect('auth/login'); }
/** * Leave new comment * * @param $input * @return static */ public function leaveComment($input) { $comment = Comment::leave($input['body'], $input['status_id']); User::findOrFail($input['user_id'])->comments()->save($comment); return $comment; }
/** * Handle the event. * * @param User $user * @internal param User $event */ public function handle(User $user) { $user->inLine = false; $user->save(); }
/** * UnFollow a user * * @param $userToUnFollow * @param User $user * @return mixed */ public function unFollow($userToUnFollow, User $user) { return $user->follows()->detach($userToUnFollow); }
/** * Shared albums by other specific user with me * * @param User $otherUser * @return mixed */ public function sharedAlbumsWithMe(User $otherUser) { $OtherUserAlbums = $otherUser->albums()->get(); $albumsSharedWithMe = $this->albumsSharedWithMe()->get(); return $OtherUserAlbums->intersect($albumsSharedWithMe); }
/** * @param User $otherUser * @return bool */ public function isFollowedBy(User $otherUser) { $idsWhoOtherUserFollows = $otherUser->follows()->lists('followed_id')->all(); return in_array($this->id, $idsWhoOtherUserFollows); }
/** * When unFollowing unShare all albums * * @param User $user * @param User $userSharingWithMe */ public function unShareAllAlbums(User $user, User $userSharingWithMe) { $albumsToUnShare = $user->sharedAlbumsWithMe($userSharingWithMe)->lists('id')->all(); $user->albumsSharedWithMe()->detach($albumsToUnShare); }