A
A
AleDv2019-04-25 16:19:50
Laravel
AleDv, 2019-04-25 16:19:50

How to use Observer when deleting a model?

Hello. I use Laravel 5.8 and use Observer to interact with CRUD operations.
Creation, update works as it should. But I ran into a problem when deleting the model.
If the Observer has deleting or deleted methods, then when I try to delete the model, I get a ValidationException with the message The given data was invalid. And the errors of my request fall out, which is used when working with a form to create / edit a model.
If the above methods are overwritten, then the removal works correctly.
Where to dig? And why does the validator twitch when deleted?
UPD . I decided myself. Passed the request to the Observera constructor. This request twitches on all operations except deletion, which is why the exception was called. The question is closed.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question