laravel/framework — pull request #1636 by PhiloNL (2013-06-13 15:31:35+00:00)
Title: Add option that allows you to disable detaching of current records

The BelongsToMany relation supports sync, attach and detach.
But there is no option to attach only new records. If you use attach() it will create duplicate entries in the relationships table.

This pull request will allow you to sync but keep existing relations.

Table
```sql
id project_id user_id
1 2 10
2 2 20
3 2 30
```

Code
```php
// Normal sync
$project->users()->sync([10]);
```
Result
```sql
id project_id user_id
1 2 10
```

Code
```php
// Sync but with detaching disabled
$project->users()->sync([40], false);
```

Result
```sql
id project_id user_id
1 2 10
2 2 20
3 2 30
3 2 40
```