I am trying to grab a model and update one of the fields but i keep receiving this error message.
Creating default object from empty value
if(isset($data['code']) && $data['code']){
$invite = \App\Invite::where('code', $data['code'])->first();
$invite->accepted = 1;
$invite->save();
}
I have never seen this error before am i grabbing the model incorrectly when updating the accepted field?
dd($invite);to see if you actually get something back$inviteis null, so you getting this error. As lagbox said already as answer. I suggest you to usefirstOrFail()instead offirst(), then it will throw a 404 error instead of this error.