i am trying to update text when i send request to Laravel controller, but i am getting error:
500 internal server error
Uncaught (in promise) Error: Request failed with status code 500
console.log is showing text and values which i am trying to send to controller:
id:16 text:aa
vue js code:
const onEdit=(todo)=>{
// var src = evt.target.innerHTML
// this.txt = src
axios
.put('http://127.0.0.1:8000/api/todo/update', {
id:todo.id,
text:todo.text
})
.then(() => getTodos());
console.log("working", todo.text, todo.id);
};
Laravel COntroller:
public function updateData(Request $request)
{
$todo = Todo::find($request->id);
$todo->update($request->all());
return response()->json([
'message' => 'updated'
]);
}
Route:
Route::put('todo/update',[TodoController::class,'updateData']);
Model:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Todo extends Model
{
use HasFactory;
protected $dates = [
'created_at',
'updated_at',
];
protected $fillable = ['id'];
}
UPDATE:
i checked laravel log and i got error:
Add [id] to fillable property to allow mass assignment on [App\Models\Todo].
Then i added id in model. now i am seeing below response in console log but it is not updating data.

