How do I add a null inside this if else statement because it's throwing Attempt to read property "civil_status_id" on null. What is the proper ternary operator to use so that it will not throw this kind of error if the database table has no value yet. I'll provide the code below
Blade.php file
<div class="col-sm-12 col-lg-4">
<div class="form-group row">
<label for="step1_civilStatus" class="col-sm-3 text-right control-label col-form-label">Civil Status</label>
<div class="col-sm-9">
<select class="form-control" type="date" id='civilStatus' >
<option>Select Civil Status</option>
@foreach($statuses as $status)
@if($status->id > 0)
@if($user->civil_status_id == $status->id )
<option value={{$status->id}} selected>{{$status->complete_name}}</option>
@else
<option value={{$status->id}}>{{$status->complete_name}}</option>
@endif
@endif
@endforeach
</select>
</div>
</div>
</div>