danultimate
1 week ago
184
15
Requests

getting undefined index with a post.

Posted 1 week ago by danultimate

I'm trying to fetch some data in a table, GET requests work ok but when I try to add a new column from the form.

Testing with postman gives me Undefined index: proveedor

This is my controller code:

public function store(Request $request)
{
    $validator = Validator::make(
        $request->all(),
        [

        ]
    );

    if ($validator->fails()) {
        return response()->json(['errors' => $validator->errors()], 403);
    } else {
        $params = $request->all();
        $suppliers = Suppliers::create([
            'proveedor' => $params['proveedor'],
            'code' => strtolower($params['proveedor']) . time(), // Just to make sure this value is unique
            'contacto' => $params['contacto'],
            'telefono' => $params['telefono'],
            'email' => $params['email'],
            'pais' => $params['pais'],
            'direccion' => $params['direccion'],
            'calidad' => $params['calidad'],
            'pedidos' => $params['pedidos'],
        ]);
        
        return new SuppliersResource($supplier);
    }
}

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