dongzhan3937 2017-04-10 15:36
浏览 42
已采纳

Laravel类别 - 子类别

I have made a Laravel application with category/subcategory layout. Both DB and models work fine with one table connected back to itself with parent_id in Category model/table.

I was wondering about the best approach for loading the items for each subcategory. The way it is done now is with jQuery which is filling the accordion class with the data by making a get request to Laravel route.

I was thinking if there is some better way to do it? Maybe loading complete subcategories data and dynamically assigning visibility or something more...Laravel type?

  • 写回答

1条回答 默认 最新

  • dougai6464 2017-04-11 07:05
    关注

    I think it's the best you can do. I don't ever recommend to load unusable data to the user and then trace it to see what to show and what to hide it resources consuming and making all categories data available in the request -maybe in html too- even for non-authorized users.

    So the best I've used and seen in packages was your current approach. I know this may be not what're expecting to see as an answer but nothing as perfect as we want it to be.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题