php - Laravel findorfail() redirect -
i have following code :
public function showtestprofile($id){ $auth = auth::user(); $tests = app\test::findorfail($id); return view('profile',compact('auth','tests','members')); }
if have id in db table come findorfail()
,
but if add not existing id url :
http://newpro.dev/user-profile/24645645456
then no query found larvel page comes up.
how can redirect route if have no id.
add uses in controller
use illuminate\database\eloquent\modelnotfoundexception;//find or fail error exception class.
and modify current code this
public function showtestprofile($id){ try{ $auth = auth::user(); $tests = app\test::findorfail($id); return view('profile',compact('auth','tests','members')); } catch(modelnotfoundexception $err){ //if id doesnt exist skip return view('profil.. //and excute whatever in section } }
@admin
ReplyDeleteOur doctors or dentists are to facilitate their advance techniques and educational experience, which provide patients with the best alternatives for oral health. Our team and dentists maintain to prepare themselves to provide maximum satisfaction for patients.
Regards,
Dentist In New Britain, CT
@admin
ReplyDeleteWe provide all the requirements around the patients to give friendly involvement with divine and relaxed circumstances. Book an appointment and visit our clinic for our effective doctor’s experiences
Regards,
Dentist In Dracut, MA
@admin
ReplyDeleteOur team takes care about dental care with excellent equipment and material in your comfortable atmosphere. Your comfort is our priority, which suits your smile as per your requirement.
Regards,
Dentist In Lynn MA
@admin
ReplyDeleteOur team takes care about dental care with excellent equipment and material in your comfortable atmosphere. Your comfort is our priority, which suits your smile as per your requirement.
Regards,
Dentist In Lynn MA