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
Watch video CakePHP 4 - Enable the Tree Behavior in a table with existing records online without registration, duration hours minute second in high quality. This video was added by user James McDonald 07 March 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 305 once and liked it 4 people.