laravel many to many relationship where code example
Example: many to many relationship laravel
use App\Models\User;
$user = User::find(1);
$user->roles()->attach($roleId);
use App\Models\User;
$user = User::find(1);
$user->roles()->attach($roleId);