Jun 29, 2017
0
Level 1
Update request not updating
Hello everyone,
I am working on a Lumen API but for some reason one of the UPDATE requests is not updating correctly. I have created an object for the objects it selfs which is working fine. But in that object I want the user to be able to add locations.
public function update(Request $request, $id, $locatieId) {
// this is returning the location id
$locatie = Location::find($locatieId);
$updated = $locatie->update($request->all());
return response()->json(['updated' => $updated]);
}
The url which I am posting to is: http://api.localhost.nl/objecten/2/locaties/1
And this is the model for the location:
namespace App;
use Illuminate\Database\Eloquent\Model;
class Location extends Model
{
protected $fillable = [
'longitude',
'latitude'
];
protected $table = 'location';
protected $hidden = array('object_id');
public function object(){
return $this->belongsTo('App\Object');
}
}
When I post the following code, it returns {"update" : true} but nothing is happening:
[
{
"longitude": "11",
"latitude": "22"
}
]
Please or to participate in this conversation.