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