vendredi 5 octobre 2018

How to solve "Trying to get property of non-object" in Laravel?

If my code return null then it generates this error. If code return some data then it works fine.

My Controller code

$profile_data= DB::table('partner_prefence')->select('*')->where('profile_id',$profile_id)->first();
return view('partner_prefence',['profile_data' =>  $profile_data]);

View :

@php($rel_status = explode(',', $profile_data->p_marital_status))

If $profile->p_marital_status has some value then no issue. the error only come when its value isn null.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire