app/Http/Controllers/Api/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)
    {
        try {
            $customer = Customer::findOrFail($id);
            $inputs = request()->all();
            $customer->first_name = isset($inputs['first_name']) ? $inputs['first_name'] : $customer->first_name;
            $customer->last_name = isset($inputs['last_name']) ? $inputs['last_name'] : $customer->last_name;
            $customer->email = isset($inputs['email']) ? $inputs['email'] : $customer->email;
            $customer->save();
            return response()->json($customer);
        } catch (Exception $e) { }
    }
public function update ( Request $ request , $ id ) { try { $ customer = Customer :: findOrFail ( $ id ) ; $ inputs = request ( ) -> all ( ) ; $ customer -> first_name = isset ( $ inputs [ 'first_name' ] ) ? $ inputs [ 'first_name' ] : $ customer -> first_name ; $ customer -> last_name = isset ( $ inputs [ 'last_name' ] ) ? $ inputs [ 'last_name' ] : $ customer -> last_name ; $ customer -> email = isset ( $ inputs [ 'email' ] ) ? $ inputs [ 'email' ] : $ customer -> email ; $ customer -> save ( ) ; return response ( ) -> json ( $ customer ) ; } catch ( Exception $ e ) { } }
Update the specified resource in storage.
Update the specified resource in storage .