I have a problem in deleting data I wrote a function in model to delete data and it works but when foreign key constraint occur it show this error:
and I want to handle this error in the code and when this error occurs I want to show an error message: You can't delete this data.