I want to prevent the user from deleting a record if it is already in use, for example: Patient-id_patient table have interaction with table Accidents or Table Appointments Clear by the primary key id_patient.
The idea is that if it already has records it is not deleted, but if it does not have to be deleted by the user. I am trying to do it by means of disabling the delete button, but I can not find how to arm the condition so that it works for me as it should.
My code is this:
<td>
<a class="btn btn-primary" href="{{ route('pacientes.edit',$paciente->id_paciente) }}" title="Editar"><span class="fas fa-edit"></span></a>
{!! Form::open(['method' => 'DELETE','route' => ['pacientes.destroy', $paciente->id_paciente],'style'=>'display:inline','onsubmit' => 'return ConfirmDeleteModel("el paciente","'.$paciente->nombre_pac.'","'.$paciente->id_paciente.'")']) !!}
@if ($paciente->hacer_condicion)
<button class='btn btn-danger' type='submit' value='submit' title="Borrar" disabled='false'> <span class='fas fa-times'> </span>
</button>
@else
<button class='btn btn-danger' type='submit' value='submit' title="Borrar" > <span class='fas fa-times'> </span>
@endif
{!! Form::close() !!}
</td>
It works to delete a record without more interactions but when wanting to eliminate a patient who has an accident or appointment I can not disable the button
I hope and you can guide me I'm relatively a Rookie in Laravel I still do not understand it well