@meglo in your migration if you have set up foreign key constraints
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
to cascade on delete then this should also update your join table to remove records.
see
https://laravel.com/docs/8.x/migrations#foreign-key-constraints
i'm not quite sure of your error though:
All records for employee id 1 in attendance_employees are also deleted. because when I delete the employee id 1, but the employee id 1 data is still in the attendance_employees table, an error will occur. how to handle it?
as you say all records are being deleted for employee but also they aren't ??