From e9627c4c4c7d6248c808eb6785dfd308b8c17744 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 4 Jun 2018 23:25:34 -0600 Subject: [PATCH] Update ProfileController --- app/Http/Controllers/ProfileController.php | 12 ++++++++++-- resources/views/profile/partial/user-info.blade.php | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 6777dbb49..565d275c6 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -61,15 +61,23 @@ class ProfileController extends Controller public function followers(Request $request, $username) { $profile = Profile::whereUsername($username)->firstOrFail(); + // TODO: fix $profile/$user mismatch in profile & follower templates + $user = $profile; + $owner = Auth::check() && Auth::id() === $user->user_id; + $is_following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false; $followers = $profile->followers()->orderBy('created_at','desc')->simplePaginate(12); - return view('profile.followers', compact('profile', 'followers')); + return view('profile.followers', compact('user', 'profile', 'followers', 'owner', 'is_following')); } public function following(Request $request, $username) { $profile = Profile::whereUsername($username)->firstOrFail(); + // TODO: fix $profile/$user mismatch in profile & follower templates + $user = $profile; + $owner = Auth::check() && Auth::id() === $user->user_id; + $is_following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false; $following = $profile->following()->orderBy('created_at','desc')->simplePaginate(12); - return view('profile.following', compact('profile', 'following')); + return view('profile.following', compact('user', 'profile', 'following', 'owner', 'is_following')); } public function savedBookmarks(Request $request, $username) diff --git a/resources/views/profile/partial/user-info.blade.php b/resources/views/profile/partial/user-info.blade.php index 13326794e..ec48c7ac2 100644 --- a/resources/views/profile/partial/user-info.blade.php +++ b/resources/views/profile/partial/user-info.blade.php @@ -14,7 +14,7 @@ - @elseif ($following == true) + @elseif ($is_following == true) - @elseif ($following == false) + @elseif ($is_following == false)