脚本宝典收集整理的这篇文章主要介绍了php – 包含在每个foreach循环迭代中重复的刀片模板,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
@foreach ( Auth::user()->unreadNotifications as $notification ) {{ $notification->tyPE->web_template }} {{ $notification->id }} @include($notification->type->web_template) @enDForeach
web_template将输出模板的路径:notifications.web.user_alert
对于循环的每次迭代,{{$notification-> type-> web_template}}和{{$notification-> id}}将输出他们应该的内容,但@include($notification-> type – > web_template)每次只输出第一个通知.
所以输出看起来像:
156 notification.web.new_message
你有来自Joe的新消息.
154 notification.web.user_alert
你有来自Joe的新消息.
145 notification.web.new_like
你有来自Joe的新消息.
我认为这可能是某种缓存问题,但我找不到任何有同样问题的人.
有任何想法吗?
示例通知视图:
@extends('layouts.notification-wrapper') @section('url',url('jobs/'.$notification->job_id.'#highlight'.$notification->bid_id)) @section('image','/assets/img/no-photo.jpg') @section('header',$notification->collector->Firstname . ' ' . $notification->collector->secondname) @section('description') has placed a bid of €{{ number_format($notification->bid()->wIThTrashed()->first()->amount,0) }} on your job. @stop
通知包装器:
<li @if(!$notification->read) class="unread" @endif> <a href="@yield('url')" data-id="{{ $notification->id }}"> <div class="pull-left"> <img src="@yield('image')" class="img-circle" alt="user image"> </div> <h4> @yield('header') <small><i class="fa fa-clock-o"></i> {{ $notification->created_at->diffForHumans()}}</small> </h4> <p> @yield('description')</p> </a> </li>
发现:Laravel Blade Templates Section Repeated / cache error
基本上无论它的工作方式如何,我都需要在循环和使用@yield时覆盖我的部分……我想.所以我需要在我的视图中用@overwrite替换@stop.
以上是脚本宝典为你收集整理的php – 包含在每个foreach循环迭代中重复的刀片模板全部内容,希望文章能够帮你解决php – 包含在每个foreach循环迭代中重复的刀片模板所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。