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