[英]Laravel 5 View Property doesn't exist Error
Here is the view i need to fulfill. 这是我需要实现的观点。
So that i need to full table data and in under to that other details need to be fill once user fill it. 因此,我需要全表数据,并且在用户填写后需要填写其他详细信息。 So here is the view for that index.blade.php 所以这是index.blade.php的视图
<table class="table table-bordered">
<thead>
<th>Name</th>
<th>Data</th>
</thead>
<tbody>
<tr>
<td>Date</td>
<td>{{ $items->date_of_programe }}</td>
</tr>
<tr>
<td>Time</td>
<td>{{ $items->time }}</td>
</tr>
<tr>
<td>Venue</td>
<td>{{ $items->venue }}</td>
</tr>
</tbody>
</table>
<table class="table table-striped">
<thead>
<th>Trainee Programe ID</th>
<th>Presenter Name</th>
<th>Division</th>
<th>Date</th>
</thead>
<tbody>
@foreach($items as $item)
<tr>
<td>{{ $item->training_programe_id }}</td>
<td>{{ $item->presenter_name }}</td>
<td>{{ $item->division }}</td>
<td>{{ $item->date }}</td>
</tr>
@endforeach
</tbody>
</table>
So here is the error i'm getting. 所以这是我得到的错误。
So this is my controller index function. 所以这是我的控制器索引功能。
public function index()
{
$items = trainingprogramedetails::all();
return view('programesession.index',compact('items'));
}
public function create()
{
return view('programesession.programes');
}
public function store(Request $request)
{
trainingprogramedetails::create($request->all());
return view('programesession.programes');
}
Here is my create view. 这是我的创建视图。
<div class="jumbotron">
<div class="form-group">
<label>Date</label>
<input class="form-control" name="date_of_programe" type="date" value="2011-08-19" id="example-date-input">
</div>
<div class="form-group">
<label>Time</label>
<input type="text" name="time" type="time" class="form-control" value="">
</div>
<div class="form-group">
<label>Venue</label>
<input type="text" name="venue" class="form-control" value="">
</div>
<div class="form-group">
<label>Training Programe Id</label>
<input type="text" name="training_programe_id" class="form-control" value="TR/PR/">
</div>
<div class="form-group">
<label>Presenter Name</label>
<input type="text" name="presenter_name" class="form-control" value="">
</div>
<div class="form-group">
<label>Division</label>
<input type="text" name="division" class="form-control" value="">
</div>
<div class="form-group">
<label>Date</label>
<input class="form-control" name="date" type="date" value="2011-08-19" id="example-date-input">
</div>
<input type="submit" class="btn btn-success pull-right">
So can anyone suggest me to solve this error? 所以有人建议我解决这个错误吗? Thank you. 谢谢。
The issue is here: 问题在于:
<td>{{ $items->date_of_programe }}</td>
The $items
is a collection of arrays, so to access its properties try: $items
是数组的集合,因此要访问其属性,请尝试:
foreach($items as $item)
{
echo $item['date_of_programe'];
}
or 要么
$items[0]->date_of_programe
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.