I tried to edit/update my data in database. But always get this error.
NotFoundHttpException in Handler.php line 102: No query results for model [App\Produk]
Here's the function in controller
:
public function update($id, Request $request)
{
$data = Produk::findOrFail($id);
$data->update($request->all());
return redirect('pages.admin.lihat');
}
And here's my edit.blade.php
form:
{!! Form::model($data,['method'=>'PATCH','url' => 'admin/update']) !!}
<div class="contact-form">
<div class="form-group">
{!! Form::label('Nama Produk') !!}
{!! Form::text('nama', null,
array('required',
'class'=>'form-control',
'placeholder'=>'Nama Produk')) !!}
</div>
<div class="form-group">
{!! Form::label('Jumlah Produk') !!}
{!! Form::number('jumlah', null,
array('required',
'class'=>'form-control',
'placeholder'=>'Jumlah Produk')) !!}
</div>
<div class="form-group">
{!! Form::label('Harga') !!}
{!! Form::text('harga', null,
array('required',
'class'=>'form-control',
'placeholder'=>'Harga')) !!}
</div>
<div class="form-group">
{!! Form::label('Gambar') !!}
{!! Form::text('images', null,
array('required',
'class'=>'form-control',
'placeholder'=>'Gambar')) !!}
</div>
<div class="form-group">
{!! Form::submit('Edit',
array('class'=>'btn btn-primary')) !!}
</div>
</div>
{!! Form::close() !!}
I use this in my routes
(the first one is for the store function so nothing to do with this update):
Route::post('admin/success','ProdukController@simpan');
Route::resource('admin','ProdukController');
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1RLnWl9
via IFTTT
Aucun commentaire:
Enregistrer un commentaire