many to many relationship laravel migration code example
Example 1: laravel many to many migration
php artisan make:migration create_posts_users_table
Example 2: many to many relationship laravel
use App\Models\User;
$user = User::find(1);
$user->roles()->attach($roleId);