laravel api to update data is not working

Discussão em 'Angular' iniciado por Rishabh, Novembro 28, 2024.

  1. Rishabh

    Rishabh Guest

    I am sending data from ionic project using api. And receiving from laravel. My "Add" product api is working fine. But "Update" product api is not working.

    I can see from browser inspection tool that Request payload got data which is being send to laravel. So, data is being send but laravel is not able to real that data.

    This is update function for api.

    public function update(Request $request, Product $product)
    {

    // Validate request
    $validatedData = $request->validate([
    'account_type' => 'required|in:1,2',
    'name' => 'required|string|max:255',
    'description' => 'nullable|string',
    'price' => 'required|numeric|min:0'
    ]);

    // Update product
    $product->update($validatedData);

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


    This is giving following error

    account_type [ "The account type field is required." ]
    name [ "The name field is required." ]
    price [ "The price field is required." ]
    and so on..


    Laravel unable to read data for some reason.

    Continue reading...

Compartilhe esta Página