SinghWithLaravel
3 months ago
665
10
Laravel

How can i delete data in larvel relation, when we have nested relations ?

Posted 3 months ago by SinghWithLaravel

I want to delete nested data with parent data in laravel relation. Default way of laravel hust provides one way, and that is defined below -

User::find($id)->profile()->delete();

I want to delete all documents related to the user while its deletion. I don't wanna use events, neither loops or cascade delete. I want something builtIn. Is it possible ?

Please sign in or create an account to participate in this conversation.