If my code return null then it generates this error. If the code returns some data, then it works fine.
Controller
$profile_data= DB::table('partner_prefence')
->select('*')
->where('profile_id',$profile_id)
->first();
return view('partner_prefence',['profile_data' => $profile_data]);
View/Blade
@php($rel_status = explode(',', $profile_data->p_marital_status))
If $profile->p_marital_status
has a value then there's no issue. The error only comes when its value is null.