在Laravel 中實(shí)現(xiàn)是否關(guān)注的示例
廢話不多說(shuō),直接上代碼!
@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">取消關(guān)注</button>
</form>
@else
<form action="{{ route('followers.store', $user->id) }}" method="post">
{{ csrf_field() }}
<button type="submit" class="btn btn-sm btn-primary">關(guān)注</button>
</form>
@endif
</div>
@endif
通過(guò)顯示不同的視圖實(shí)現(xiàn)。
以上這篇在Laravel 中實(shí)現(xiàn)是否關(guān)注的示例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
laravel 解決groupBy時(shí)出現(xiàn)的錯(cuò)誤 isn''t in Group By問(wèn)題
今天小編就為大家分享一篇laravel 解決groupBy時(shí)出現(xiàn)的錯(cuò)誤 isn't in Group By問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-10-10
php+ajax 實(shí)現(xiàn)輸入讀取數(shù)據(jù)庫(kù)顯示匹配信息
這篇文章主要介紹了php+ajax 實(shí)現(xiàn)輸入讀取數(shù)據(jù)庫(kù)顯示匹配信息的相關(guān)資料,需要的朋友可以參考下2015-10-10
php實(shí)現(xiàn)utf-8轉(zhuǎn)unicode函數(shù)分享
這篇文章主要介紹了php實(shí)現(xiàn)utf-8轉(zhuǎn)unicode函數(shù)分享,需要的朋友可以參考下2015-01-01
WordPress免插件實(shí)現(xiàn)面包屑導(dǎo)航的示例代碼
這篇文章主要介紹了WordPress免插件實(shí)現(xiàn)面包屑導(dǎo)航,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-08-08
PHP中使用gettext解決國(guó)際化問(wèn)題的例子(i18n)
這篇文章主要介紹了PHP中使用gettext解決國(guó)際化問(wèn)題的例子,即實(shí)現(xiàn)i18n,需要的朋友可以參考下2014-06-06
Zend Framework連接Mysql數(shù)據(jù)庫(kù)實(shí)例分析
這篇文章主要介紹了Zend Framework連接Mysql數(shù)據(jù)庫(kù)的方法,以完整實(shí)例形式分析了Zend Framework連接MySQL數(shù)據(jù)庫(kù)的具體步驟與相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-03-03

