0

I need to sync 3 values in a table in which, I have 3 fields in a table as difficulty_level_id, sbj_type_id and subject_id and I have setup this thing in my Controller as:

public function store(Request $request)
{
    $difficulty_level = DifficultyLevel::find(1);
    $difficulty_level->sbj_types()->sync($request->veryeasy, false);
    return 'done';
}

but the problem is that it only attaches 2 values as difficulty_level_id and sbj_type_id. How I sync the third values as subject_id, any help will be appreciated?

  • That's not what `sync()` is meant for though, right? From the [docs](https://laravel.com/docs/5.7/eloquent-relationships): *You may also use the sync method to construct many-to-many associations. The sync method accepts an array of IDs to place on the intermediate table. Any IDs that are not in the given array will be removed from the intermediate table.* – Mozammil Feb 07 '19 at 14:17
  • So is there any other way to do this? –  Feb 07 '19 at 14:23

0 Answers0