app/Http/Controllers/OrdersController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request, Customer $customer)
    {
        $data = $request->validate([
            'branch' => 'required | not_in: 0',
            'service' =>'required | not_in: 0',
            'transportation' =>'required | not_in: 0',
            'pickup_location' => '',
            'dropin_location' => 'required',
            'kilo' => 'required',
            'pickupdate' => 'required',
        ]);
         $customer->orders()->create([
            'branch_id' => $data['branch'],
            'service' => $data['service'],
            'transportation' => $data['transportation'],
            'pickup_location' => $data['pickup_location'],
            'dropin_location' =>  $data['dropin_location'],
            'kilo' => $data['kilo'],
            'pickupdate' => $data['pickupdate'],
        ]);
        return  redirect()->route('customers.orders',[$customer])->with('success','Your order successfully added!');
    }
public function store ( Request $ request , Customer $ customer ) { $ data = $ request -> validate ( [ 'branch' => 'required | not_in: 0' , 'service' => 'required | not_in: 0' , 'transportation' => 'required | not_in: 0' , 'pickup_location' => '' , 'dropin_location' => 'required' , 'kilo' => 'required' , 'pickupdate' => 'required' , ] ) ; $ customer -> orders ( ) -> create ( [ 'branch_id' => $ data [ 'branch' ] , 'service' => $ data [ 'service' ] , 'transportation' => $ data [ 'transportation' ] , 'pickup_location' => $ data [ 'pickup_location' ] , 'dropin_location' => $ data [ 'dropin_location' ] , 'kilo' => $ data [ 'kilo' ] , 'pickupdate' => $ data [ 'pickupdate' ] , ] ) ; return redirect ( ) -> route ( 'customers.orders' , [ $ customer ] ) -> with ( 'success' , 'Your order successfully added!' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .