relation many to many on one table laravel 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);