douxi3404 2018-08-03 12:21
浏览 43
已采纳

在Laravel 5.6中放置用于格式化DB内容的代码的位置

I'm new in Laravel (and in frameworks general) and not sure about the right "place" for a formatting function.

A short desciption of my problem: Different tables refer to an enumeration table. The enumeration table keeps a link to an icon, a color, a name and a describtion. I need to format this information in different ways. e.g. "simple" name "detailed" name, description etc...

Now I'm not sure what's best place to put the code:

  • create a custom helper seems to be a too generic place for such issue
  • putting in in the model would be the easiest way but seems to me violaton of MVC.
  • the view violates the "don't repeat yourself" because I need it in different views
  • the template itself? maybe..
  • or create a dedicated blade like phpincludes.enumerationfomat ?

Thanks in advance, Christian

  • 写回答

1条回答 默认 最新

  • dqzg62440 2018-08-03 17:02
    关注

    I would like to solve:

    The answer is: "component"

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

报告相同问题?