Pluck with Where condition
I found the mistake. I should use pluck with where condition like below.
$specialities = Speciality::where('role_id',$request->roleid)->pluck('name','id');
Pluck won't filter anything, but it gives only what needed. So filtering has to be done before that.