@if ($user->id !== Auth::user()->id)
<div id="follow_form">
@if (Auth::user()->isFollowing($user->id))
<form action="{{ route('followers.destroy', $user->id) }}" method="post">
{{ csrf_field() }}
{{ method_field('DELETE') }}
<button type="submit" class="btn btn-sm">取消关注</button>
</form>
@else
<form action="{{ route('followers.store', $user->id) }}" method="post">
{{ csrf_field() }}
<button type="submit" class="btn btn-sm btn-primary">关注</button>
</form>
@endif
</div>
@endif
通过显示不同的视图实现。
文章来源:刘俊涛的博客
地址:http://www.cnblogs.com/lovebing
欢迎关注,有问题一起学习欢迎留言、评论。