app/Http/Controllers/CustomerController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        $this->validate($request, [
            'name' => 'required',
            'age' => 'required|integer|gt:0',
            'gender' => 'required',
            'contact' => 'nullable|regex:/^((?:(0))[0-9]{9})$/',
        ]);
        $customer = Customer::findOrFail($id);
        $customer->name = $request->input('name');
        $customer->age = $request->input('age');
        $customer->gender = $request->input('gender');
        $customer->contact = $request->input('contact');
        $customer->address = $request->input('address');
        $customer->save();
        return redirect('/customers');
    }
public function update ( Request $ request , $ id ) { $ this -> validate ( $ request , [ 'name' => 'required' , 'age' => 'required|integer|gt:0' , 'gender' => 'required' , 'contact' => 'nullable|regex:/^((?:(0))[0-9]{9})$/' , ] ) ; $ customer = Customer :: findOrFail ( $ id ) ; $ customer -> name = $ request -> input ( 'name' ) ; $ customer -> age = $ request -> input ( 'age' ) ; $ customer -> gender = $ request -> input ( 'gender' ) ; $ customer -> contact = $ request -> input ( 'contact' ) ; $ customer -> address = $ request -> input ( 'address' ) ; $ customer -> save ( ) ; return redirect ( '/customers' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//VALIDATION // UPDATE CUSTOMER