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)
@csrf @@ -22,7 +22,7 @@
- @elseif ($following == false) + @elseif ($is_following == false)
@csrf