in the pivot table (sentence_id), I want each combination to have only one entries, but it is allow multiple entries with exactly the same word sentence pair.
To ensure that each combination of word and sentence has only one entry in the pivot table, you can use the sync() method instead of save() method. The sync() method will remove any existing entries for the given sentence and then add the new entry. Here's an example:
$sentence->words()->sync([$word->id]);
This will remove any existing entries for the given sentence and then add the new entry for the given word.