laravel belongstomany prevent duplicates attach

Solutions on MaxInterview for laravel belongstomany prevent duplicates attach by the best coders in the world