Code: https://github.com/toggenation/cakeph...
Q: How do you manage the lft and rght column values? A: You don't the Tree Behavior does!
00:00 Intro - What will be covered
01:00 Create Trees table using a migration
02:35 Bake the Model/View (templates)/Controllers for the Trees table
05:00 Create a migration to Tree Behavior enable the Trees table
07:00 Add Tree Behavior to TreesTable Class
08:30 Get CakePHP 4 to build the tree structure using recover()
09:00 Add a @mixin annotation to a class to get Tree Behavior vscode method auto-complete working
11:00 Protect the tree structure in the database by making lft and rght not-nullable
14:00 Add parent_id field to allow linking an item to a parent
17:20 Remove mass assignment protection to allow parent_id to save
18:15 Add visual indication of parent / child relationship to index template
20:00 Using the getLevel method to find the level of an tree node
22:20 How Tree Behavior methods manages lft and rght values
24:20 Transferring moveUp/moveDown/removeFromTree actions into the TreesController and index template
28:15 Conclusion: The lft and rght fields are managed by the Tree Behavior
Смотрите видео CakePHP 4 - Enable the Tree Behavior in a table with existing records онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь James McDonald 07 Март 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 305 раз и оно понравилось 4 людям.