When I’m going to update the SEO as admin from the frontend it shows me the error “Attempt to read property “id” on null” I’ve attached the error ss. Please help me asap.

This is my controller Code
public function updateSEO(Request $request)
{
// first, get the language info from db
$language = Language::where('code', $request->language)->first();
$langId = $language->id;
// then, get the seo info of that language from db
$seo = SEO::where('language_id', $langId)->first();
// else update the existing seo info of that language
$seo->update($request->all());
$request->session()->flash('success', __('Updated successfully!'));
return redirect()->back();
}
This Is My View Code
<div class="form-group">
<label>{{ __('Meta Description For Home Page') }}</label>
<textarea class="form-control" name="home_meta_description" rows="5"
placeholder="{{ __('Enter Meta Description') }}">{{ $data->home_meta_description }}</textarea>
</div>