/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($name) { $user = User::with(['statuses' => function ($query) { $query->latest(); }])->whereName($name)->first(); return view('users.show')->withUser($user); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $userIdToFollow = $request->userIdToFollow; $followed = User::findOrFail($userIdToFollow); \Auth::user()->followedUsers()->attach($userIdToFollow); return \Redirect::back(); //return \Auth::user(); }
/** * A basic functional test example. * * @return void */ public function a_user_may_register_for_an_account_but_must_confirm_their_email_address() { $this->visit('register')->type('JohnDoe', 'name')->type('*****@*****.**', 'email')->type('password', 'password')->press('Register'); // We should have an account - but one that is not yet confirmed/verified. $this->see('Please confirm your email address.')->seeInDatabase('users', ['name' => 'JohnDoe', 'verified' => 0]); $user = User::whereName('JohnDoe')->first(); // You can't login until you confirm your email address. $this->login($user)->see('Could not sign you in.'); // Like this... $this->visit("register/confirm/{$user->token}")->see('You are now confirmed. Please login.')->seeInDatabase('users', ['name' => 'JohnDoe', 'verified' => 1]); }
/** * @param $userId * @param $statusId * @param $body * @return Comment */ public function leaveComment($userId, $statusId, $body) { $comment = Comment::leave($body, $statusId); User::findOrFail($userId)->comments()->save($comment); return $comment; }
public function isFollowedBy(User $otherUser) { $idsWithOtherUserFollows = $otherUser->followedUsers()->lists('followed_id'); $idsWithOtherUserFollows = array_values((array) $idsWithOtherUserFollows)[0]; return in_array($this->id, $idsWithOtherUserFollows); }
/** * Confirm a user's email address. * * @param string $token * @return mixed */ public function confirmEmail($token) { User::whereToken($token)->firstOrFail()->confirmEmail(); dd('You are now confirmed. Please login.'); return redirect('login'); }