這是我需要履行的觀點。 Laravel 5查看屬性不存在錯誤
因此,我需要全表數據,並在其他細節需要填寫一次用戶填寫它。因此,這裏是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>
所以這是我的控制器指數函數。
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');
}
這是我的創建視圖。
<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">
因此,誰能建議我來解決這個問題? 謝謝。
嘛錯誤消息相當不言自明。你能告訴我們你的控制器中dd($ items)的結果嗎? – Mozammil
'$ items'將與數組的集合,所以你不能沒有索引來訪問它,嘗試'$項目[0] - > date_of_programe' –
先生嗯新的laravel可以請你說我什麼是DD($項目) – Dasun