0
I’m having trouble deleting a record to which your primary key was referenced in another record from another table!
The tables are discipline and teacher, where the primary key of teacher is being referenced in the table discipline!
I wanted to know the correct way to treat this exception to return a message/warning without error in the system with the default message from Larable!
Note: I don’t want to use the method cascade
, only to inform that it cannot be excluded because the teacher has relation to a discipline!
public function delete(Request $dados)
{
DB::table('professors')->where('cdprofessor', '=', $dados->cdprofessor)->delete();
return redirect()->route('professor')->withStatus(__('Professor deletado com sucesso.'));
}
How is your action
delete()
– Erlon Charles
public function delete(Request $dados){ 
 DB::table('professors')->where('cdprofessor', '=', $dados->cdprofessor)->delete();
 return redirect()->route('professor')->withStatus(__('Professor deletado com sucesso.'));
}
– Erikles Bonfim Ribeiro