how to use attach method in laravel code example Example: latavel attach method $user->roles()->attach($roleId, ['expires' => $expires]);