laravel 5.4中实现无限级分类的方法示例

(编辑:jimmy 日期: 2025/9/19 浏览:2)

前言

本文主要给大家介绍的是关于laravel 5.4中实现无限级分类的相关内容,分享出来供有需要的朋友们参考学习,下面话不多说,来一起看看详细的介绍吧。

方法如下:

1、建立表

php artisan make:migration create_category_table --create=category

在database/migrations/下找到你的迁移文件

建入:

<"htmlcode">
php artisan make: model Category -m
<"htmlcode">
$categorys = App/Category::with('allChildrenCategorys')->first();

$categorys->allChildrenCategorys; 

$categorys->allChildrenCategorys->first()->allChildrenCategorys;

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者使用laravel能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对的支持。