dongshi6969 2018-06-14 12:32
浏览 138

使用Laravel 5.6在包含的视图中传递数据

Using Laravel 5.6, I'm trying to get the number of received links a logged-in user may have in my application.

public function getReceivedLinksCount() {
    return $count = App\Link::where([
                ['recipient_id', Auth::id()],
                ['sender_id', '!=', Auth::id()]

So far, so good. Question is not about that piece of code, but where I can use it. I'd like to display this counter on the navigation bar of the website (Facebook's style) which is in my header.blade.php which is included in every page.

I'd like to do it with a clean code, of course. It seems like I need to use View Composers but I'm not sure it's the right way to do it, and not sure on how the code is supposed to look.

  • 写回答

2条回答 默认 最新


      相关推荐 更多相似问题


      • ¥15 写c++代码,第7题说一下使用的计算方法
      • ¥15 有关c++的问题,利用相关知识
      • ¥15 求香农编码和解码的matlab代码
      • ¥20 ROS中的TEB局部规划问题
      • ¥20 关于#matlab#的问题:要求测出上面图片中所有同心圆的半径
      • ¥20 epanet软件运行问题
      • ¥15 Python 文件读取
      • ¥60 dpabi进行Alff计算时脑池有干扰信号
      • ¥15 利用kmeans或kshape聚类分析对归一化的无量纲时间-降雨序列进行聚类
      • ¥15 protel99.SE提示一下弹窗