public function update(Request $request, $id)
    {
        $rules = [
            "address" => "required|max:256",
            "country" => "required",
            "label" => "required|max:50",
            "municipality" => "required|max:128",
            "postcode" => 'required|regex:/^[0-9]{5}(-\d{4})?$/',
            "stateProvince" => "required",
        ];
        /** @noinspection PhpUndefinedMethodInspection */
        $request->validate($this->addPolymorphicRules($rules, 'addressable', $request->addressableType));
        $address = Address::findOrFail($id);
        $this->authorize('manage', $address);
        $address->label = $request->label;
        $address->address = $request->address;
        $address->municipality = $request->municipality;
        $address->state_province = $request->stateProvince;
        $address->postcode = $request->postcode;
        $address->country = $request->country;
        $address->save();
        return fractal($address, new AddressTransformer())
            ->withResourceName('address')
            ->respond();
    }
public function update(Request $request, $id)
    {
        $rules = [
            "address" => "required|max:256",
            "country" => "required",
            "label" => "required|max:50",
            "municipality" => "required|max:128",
            "postcode" => 'required|regex:/^[0-9]{5}(-\d{4})?$/',
            "stateProvince" => "required",
        ];
        /** @noinspection PhpUndefinedMethodInspection */
        $request->validate($this->addPolymorphicRules($rules, 'addressable', $request->addressableType));
        $address = Address::findOrFail($id);
        $this->authorize('manage', $address);
        $address->label = $request->label;
        $address->address = $request->address;
        $address->municipality = $request->municipality;
        $address->state_province = $request->stateProvince;
        $address->postcode = $request->postcode;
        $address->country = $request->country;
        $address->save();
        return fractal($address, new AddressTransformer())
            ->withResourceName('address')
            ->respond();
    }
public function update ( Request $ request , $ id ) { $ rules = [ "address" => "required|max:256" , "country" => "required" , "label" => "required|max:50" , "municipality" => "required|max:128" , "postcode" => 'required|regex:/^[0-9]{5}(-\d{4})?$/' , "stateProvince" => "required" , ] ; /** @noinspection PhpUndefinedMethodInspection */ $ request -> validate ( $ this -> addPolymorphicRules ( $ rules , 'addressable' , $ request -> addressableType ) ) ; $ address = Address :: findOrFail ( $ id ) ; $ this -> authorize ( 'manage' , $ address ) ; $ address -> label = $ request -> label ; $ address -> address = $ request -> address ; $ address -> municipality = $ request -> municipality ; $ address -> state_province = $ request -> stateProvince ; $ address -> postcode = $ request -> postcode ; $ address -> country = $ request -> country ; $ address -> save ( ) ; return fractal ( $ address , new AddressTransformer ( ) ) -> withResourceName ( 'address' ) -> respond ( ) ; }
Update an Address
@param  \Illuminate\Http\Request $request current Request object
@param string $id UUID of Address to update
@return \Illuminate\Http\Response JSON response with updated Address attributes
Update an Address