Can be achieved through a model-tree to a tree-like components, you can drag the way to achieve the level of data, sorting and other operations, the following is the basic usage.
Table structure and model
To use model-tree, you have to follow the convention of the table structure:
CREATETABLE `demo_categories` (`id`int(10) unsigned NOT NULL AUTO_INCREMENT,`parent_id`int(11) NOT NULLDEFAULT'0',`order`int(11) NOT NULLDEFAULT'0',`title`varchar(50) COLLATE utf8_unicode_ci NOT NULL,`created_at`timestampNOT NULLDEFAULT CURRENT_TIMESTAMP,`updated_at`timestampNOT NULLDEFAULT CURRENT_TIMESTAMP ONUPDATE CURRENT_TIMESTAMP,PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
The above table structure has three necessary fields parent_id, order, title, and the other fields are not required.
The corresponding model is app/Models/Category.php: