samedi 23 février 2019

How to update row using API laravel?

I use the following route resource:

Route::apiResource('events', 'EventController');

EventController is:

public function update(UpdateEvent $request)
    {

        $model = Event::find($request->id)->update([
            "name" => $request->name,
            "date" => $request->date,
        ]);

        return response()->json($model);
    }

I send PUT request in JSON format to this endpoint /api/events.

Result error message is:

MethodNotAllowedHttpException
No message

So, I dont want pass id to url, I want transmit all data in PUT body request.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire