danultimate
3 months ago

PUT http://127.0.0.1:8000/api/suppliers/ 405 (Method Not Allowed)

Posted 3 months ago by danultimate

Im working on a code that should add or update new "suppliers"

after filling the form Im getting the error 405

Here is my update function of the controller.

public function update(Request $request, Suppliers $suppliers) { if ($suppliers === null) { return response()->json(['error' => 'Supplier not found'], 404); }

$validator = Validator::make(
    $request->all(),
    [

    ]
);

if ($validator->fails()) {
    return response()->json(['errors' => $validator->errors()], 403);
} else {
    $params = $request->all();
    $suppliers->proveedor = $params['proveedor'];
    $suppliers->contacto = $params['contacto'];
    $suppliers->telefono = $params['telefono'];
    $suppliers->email = $params['email'];
    $suppliers->pais = $params['pais'];
    $suppliers->direccion = $params['direccion'];
    $suppliers->calidad = $params['calidad'];
    $suppliers->pedidos = $params['pedidos'];
    $category->save();
}

return new SuppliersResource($suppliers);

}

/**
 * Remove the specified resource from storage.
 *
 * @param  \App\Laravue\Models\Suppliers  $suppliers
 * @return \Illuminate\Http\Response
 */
public function destroy(Suppliers $suppliers)
{
    //
}

}

Please sign in or create an account to participate in this conversation.