I am assigning multiple skills to an employee using checkboxes. when a user checks the checkbox a new record is inserted into pivot table. if a user unchecks the checkbox a record is deleted.
Now i am wondering if there is any function for insert or delete like there exists for new insert or update which is updateOrCreate to update an existing record or create a new record if none exists.
I can do it the hard way. but just want to know if there is any function for this like updateOrCreate.
Use the
syncmethod it will replace the old values to new.$employee->skill()->sync($request->checkedSkill)