laravel attach if exists code example Example: laravel attach once $user->roles()->syncWithoutDetaching([1, 2, 3]);