我正在使用laravel v 4.2 .. 我想創建更新記錄。 你能幫助我..什麼不對的代碼... 這是我的代碼:
MatakuliahsController.php
public function edit($id) { //$matakuliahs = $this->matakuliahs->find($id); $matakuliahs = Matakuliah::where('id','=',$id)->get(); if(is_null($matakuliahs)){ return Redirect::route('matakuliahs.index'); } return View::make('matakuliahs.edit',compact('matakuliahs')); }
edit.blade.php
{{ Form::open(array('autocomplete' => 'off', 'method' => 'PATCH', 'route' => array('matakuliahs.update', $matakuliahs->id))) }} ... {{ Form::close() }}
錯誤是:
Undefined property: Illuminate\Database\Eloquent\Collection::$id (View: C:\xampp\htdocs\Laravel 4\projectLaravel\app\views\matakuliahs\edit.blade.php)
感謝您的關注和您的幫助..