Someone help me with this error that already has me with a headache please
Controller part of Update :
public function edit($id)
{
return view("almacen.categoria.edit",["categoria"=>Categoria::findOrFail($id)]);
}
public function update(CategoriaFormRequest $request,$id)
{
$categoria=Categoria::findOrFail($id);
$categoria->nombre=$request->get('nombre');
$categoria->descripcion=$request->get('descripcion');
$categoria->update();
return Redirect::to('almacen/categoria');
}
The Update view :
@extends ('layouts.admin')
@section ('contenido')
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<h3>Editar Categoría: {{ $categoria->nombre}}</h3>
@if (count($errors)>0)
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{$error}}</li>
@endforeach
</ul>
</div>
@endif
{!!Form::model($categoria,['method'=>'PATCH','route'=>['almacen.categoria.update',$categoria->idcategoria]])!!}
{{Form::token()}}
<div class="form-group">
<label for="nombre">Nombre</label>
<input type="text" name="nombre" class="form-control" value="{{$categoria->nombre}}" placeholder="Nombre...">
</div>
<div class="form-group">
<label for="descripcion">Descripción</label>
<input type="text" name="descripcion" class="form-control" value="{{$categoria->descripcion}}" placeholder="Descripción...">
</div>
<div class="form-group">
<button class="btn btn-primary" type="submit">Guardar</button>
<button class="btn btn-danger" type="reset">Cancelar</button>
</div>
{!!Form::close()!!}
</div>
</div>
@endsection
Category table image...
Your primary key is called idcategory not called id! Set in the model:
Cheers
Dear change it for this value