php - Laravel 7 updateOrCreate does not working

I'm having a weird problem with theupdateOrCreate
function. If I the record is new there is no problem. But if the record exists it never gets updated. For example, I make this call, and it seems it's updated.
blade
<form action="{{ route('updateOrCreate') }}" method="post">
@csrf
<div class="ms-4">
<div class="form-check">
<input class="form-check-input" type="radio" value="1" id="yes" name="question" {{ optional(auth()->user()->skillMaster)->question == 1 ? 'checked' : '' }}>
<label class="form-check-label" for="yes">
Yes
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" value="0" id="no" name="question" {{ optional(auth()->user()->skillMaster)->question == 0 ? 'checked' : '' }}>
<label class="form-check-label" for="no">
No
</label>
</div>
</div>
<div class="mt-4">
<div class="col-md-4">
<label for="skill_name">Skill name</label>
<input type="text" class="form-control" id="skill_name" name="skill_name" value="{{ optional(auth()->user()->skillMaster)->skill_name }}">
</div>
<div class="col-md-4">
<label for="year_obtaining_license">Year</label>
<input type="text" class="form-control" id="year_obtaining_license" name="year_obtaining_license" value="{{ optional(auth()->user()->skillMaster)->year_obtaining_license }}">
</div>
<div class="col-md-4">
<label for="educational_background">Educational</label>
<input type="text" class="form-control" id="educational_background" name="educational_background" value="{{ optional(auth()->user()->skillMaster)->educational_background }}">
</div>
</div>
<div class="mt-4">
<button type="submit" class="btn btn-success">Save</button>
</div>
</form>
web.php
Route::post('skillMaster/store', 'SkillMasterController@updateOrCreate')->name('updateOrCreate');
SkillMasterController.php
public function updateOrCreate(Request $request, SkillMaster $skillMaster)
{
SkillMaster::updateOrCreate([
'user_id' => $skillMaster->user_id
], [
'user_id' => auth()->id(),
'question' => $request->question,
'skill_name' => $request->skill_name,
'year_obtaining_license' => $request->year_obtaining_license,
'educational_background' => $request->educational_background,
]);
return redirect()->back();
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the process class relies on proc_open, which is not available on your php installation.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.