Answer the question
In order to leave comments, you need to log in
How do I redistribute child elements if the parent is deleted?
Hello. There is a table for example category with fields id | name | parent_id
For example, there is such data in the table
Here is a link to json https://jsoneditoronline.org/?id=575f6dafdca44bbf9...
Or an array below
stdClass Object
(
[1] => stdClass Object
(
[name] => q
[children] => stdClass Object
(
[3] => stdClass Object
(
[name] => e
[parent_id] => 1
[children] => stdClass Object
(
[4] => stdClass Object
(
[name] => r
[parent_id] => 3
)
[5] => stdClass Object
(
[name] => r
[parent_id] => 3
)
)
)
[6] => stdClass Object
(
[name] => y
[parent_id] => 1
[children] => stdClass Object
(
[7] => stdClass Object
(
[name] => u
[parent_id] => 6
)
)
)
)
)
)
Answer the question
In order to leave comments, you need to log in
Subscribe to event deleting
/ deleted
models and distribute child elements to other elements.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question