douguachi0056 2015-08-27 22:31
浏览 66

在Laravel中创建动态标签并将变量传递给它们

I have a form that creates a project. A project can have a few external links. For example, it can have a link to Behance, deviantART, YouTube, Facebook and so on. Some might not have any links at all. If a project has Behance or deviantART or Facebook link, then when viewing the project, it should say:

View [project name] on [social network name].

If it has a link to YouTube, it should say:

Watch [project name] on YouTube.

And some other link can have custom 'labels' so to say.

Of course I could do an if statement, but I believe there's an easier way to do this using something like Lang maybe? The only thing I don't understand is - how can I pass that [project name] to the Lang option?

  • 写回答

1条回答 默认 最新

  • dpqjvoq9033 2015-08-28 19:02
    关注

    Solved this with lang / trans() function and simple sprintf().

    评论

报告相同问题?