Answer the question
In order to leave comments, you need to log in
Why is the update method not working in laravel controller?
update(id, params) {
console.log(params); // отправляются
ajax.put(`/admin/sites/update/${id}`,params).then(
(response) => {
console.log(response);
console.log('Сохранено')
},
(err) => {
console.log(err.response);
}
);
},
// приходит success но не сохраняет
public function update($id, Request $request)
{
$site = Site::find($id);
$site -> fill($request->all());
return response()->json([
'success' => $site->save(),
]);
}
// Integrity constraint violation: 1062 Duplicate entry
// вроде понятно с чем связана ошибка решил её способом выше но не сохраняются изменения
public function update(Request $request, Site $site)
{
$site -> fill($request->all());
return response()->json([
'success' => $site->save(),
]);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question