之前我們介紹了todo::all()這個概念,除了all(),還有別的static function
$todo = todo::orderBy("created_at", 'desc')->get()
回到我們剛剛寫的主頁面,
這里我們開始要結(jié)合show了
我沒讓每個todo有一個link
<a href='todo/{{$item->id}}'>{{$item->text}}</a>
這里要說明,當todo/id的時候,這個已經(jīng)滿足了show(展現(xiàn)某個單獨的element的條件,自然zairesource里面要分配到了show function)
在show中我們構(gòu)建
根據(jù)id,到database里面尋找,最后根據(jù)id返回數(shù)據(jù)
public function show($id)
{
$todo = todo::find($id);
return $todo;
}
********************************** 總結(jié) **********************************
這里,我們總結(jié),show這個東西該怎么用,基本上就是根據(jù)todo/「參數(shù)」的形式來尋找單個的數(shù)據(jù)