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