IvanRadojevic
1 month ago
182
4
Laravel

Validation doesn`t work

Posted 1 month ago by IvanRadojevic

This is happening to me for the first time,

Inputa data is entered in the form fields and I get validation errors for all fields, and i cant send request. Without validation part code is working?!?

public function store(Request $request)
    {
        $request->validate([
            'billing_name' => ['required'],
            'billing_address' => ['required'],
            'billing_zip' => ['required'],
            'billing_city' => ['required'],
            'billing_email' => ['required'],
            'billing_phone' => ['required'],               
        ]);

        $order = Order::create([                
            'billing_name' => $request->name,
            'billing_address' => $request->address,
            'billing_zip' => $request->zip,
            'billing_city' => $request->city, 
            'billing_email' => $request->email,
            'billing_phone' => $request->phone,
            'billing_totalprice' => Cart::subtotal(),
            'billing_quantity' => Cart::count(),
        ]);
        
        //create concert_order
        foreach (Cart::content() as $item) {
            ConcertOrder::create([
                'order_id' => $order->id,
                'concert_id' => $item->model->id,
                'quantity' => $item->qty,
            ]);
        }
           
        Cart::instance('default')->destroy();
        
        return redirect('/');             
    }

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