大家,前幾天,我問一個可能的解決方案Try和Catch在一個函數中,我通過$ id,但現在,我有類似的問題,現在,我不' t需要傳遞任何$ id,只是一個視圖,該視圖有一個從我的應用程序的管理面板上傳的文件(PDF),我試圖說明一些管理員刪除文件(PDF),並且用戶嘗試訪問頁面的條款和條件沒有任何PDF上傳,系統重定向到其他頁面,如家;這是我的代碼:
public function terms()
{
try {
$terms = Multimedia::where('multimedia_type', 'terms')->first();
return view('terms.terms', compact('terms'));
} catch (\Exception $e) {
return redirect('/')->with('errors', 'Ha ocurrido un errror, lo sentimos');
}
}
但是,當我刪除的文件,我得到這個錯誤:
(2/2) ErrorException Trying to get property of non-object (View: /home/vagrant/Code/Biblio/resources/views/terms/terms.blade.php)
而且系統也沒有重定向到其他頁面。如果有人能幫忙,我會非常感謝
terms.blade.php中存在哪些代碼? –