我正在尝试将相同的值传递给多个视图,但我只能将其传递给一个(pages.days)。
当我点击日期/ {{$ id}}结束点时,我得到了$ id的值,它显示在我的页面中而不是appdashTest刀片文件
如何在两个视图中同时显示$ id的值?
public function show($id)
{
$allDays = Days::all();
return view('pages.days', ['trip_id' => $id])
->with(['allDays' => $allDays])
->with('layouts.appdashTest');
}
<h1>Trip Id {{$trip_id}}</h1>
<form action="/days" method="post" role="form">
<legend>Create New Days</legend>
<div class="form-group">
{{csrf_field()}}
<input type="hidden" name="id" value={{$trip_id}}>
</div>
<button type="submit" class="btn btn-primary">New Days</button>
</form>
<ul class="nav navbar-nav">
<li class="text-center"><a href="#"><i class="trvlrs-calendar"></i></a></li>
<li class="text-center"><a href="{{$trip_id}}/invitation"><i class="trvlrs-mail"></i></a></li>
<li class="text-center"><a href="/discovery"><i class="trvlrs-location"></i></a></li>
<li class="text-center"><a href="#"><i class="trvlrs-banknote"></i></a></li>
</ul>
答案 0 :(得分:1)
包括您的文件appdashTest.blade.php
,如下所示:
@include('appdashTest.blade.php', ['trip_id' => $trip_id])
public function show($id)
{
return view('pages.days', [
'trip_id' => $id,
'allDays' => Days::all(),
]);
}
<h1>Trip Id {{$trip_id}}</h1>
<form action="/days" method="post" role="form">
<legend>Create New Days</legend>
<div class="form-group">
{{csrf_field()}}
<input type="hidden" name="id" value={{$trip_id}}>
</div>
<button type="submit" class="btn btn-primary">New Days</button>
</form>
<!-- Add this where you want your appdashTest.blade.php -->
@include('appdashTest.blade.php', ['trip_id' => $trip_id])
<ul class="nav navbar-nav">
<li class="text-center"><a href="#"><i class="trvlrs-calendar"></i></a></li>
<li class="text-center"><a href="{{$trip_id}}/invitation"><i class="trvlrs-mail"></i></a></li>
<li class="text-center"><a href="/discovery"><i class="trvlrs-location"></i></a></li>
<li class="text-center"><a href="#"><i class="trvlrs-banknote"></i></a></li>
</ul>