@php
$authId = auth()->id();
// Find any friendship row between auth and this $user
$friendship = \App\Models\FriendShip::where(function ($query) use ($authId, $user) {
$query->where(function ($q) use ($authId, $user) {
$q->where('sender_id', $authId)
->where('receiver_id', $user->id);
})->orWhere(function ($q) use ($authId, $user) {
$q->where('sender_id', $user->id)
->where('receiver_id', $authId);
});
})->first();
@endphp
@if($friendship)
{{-- 1) PENDING --}}
@if($friendship->status === 'pending')
@if($friendship->sender_id === $authId)
{{-- Auth has sent to $user --}}
Request
Sent
@else
{{-- Auth is the receiver; show Accept / Pass --}}
@endif
{{-- 2) ACCEPTED --}}
@elseif($friendship->status === 'accepted')
Followed
{{-- 3) DECLINED or CANCELED --}}
@elseif(in_array($friendship->status, ['declined','canceled']))
Passed
{{-- 4) Safety fallback --}}
@else
Unknown
@endif
{{-- 5) NO friendship row at all: show Follow button --}}
@else
Follow
@endif