public function update(Request $request, $id)
    {
        /** @noinspection PhpUndefinedMethodInspection */
        $request->validate([
            "countryCode" => 'required|regex:/\d{1,2}/',
            "label" => "required|max:50",
            "phoneNumber" => 'required|regex:/\d{10}/',
        ]);
        $phone = Phone::findOrFail($id);
        $this->authorize('manage', $phone);
        $phone->country_code = $request->countryCode;
        $phone->label = $request->label;
        $phone->phone_number = $request->phoneNumber;
        $this->authorize('manage', $phone);
        $phone->save();
        return fractal($phone, new PhoneTransformer())
            ->withResourceName('phone')
            ->respond();

    }
public function update(Request $request, $id)
    {
        /** @noinspection PhpUndefinedMethodInspection */
        $request->validate([
            "countryCode" => 'required|regex:/\d{1,2}/',
            "label" => "required|max:50",
            "phoneNumber" => 'required|regex:/\d{10}/',
        ]);
        $phone = Phone::findOrFail($id);
        $this->authorize('manage', $phone);
        $phone->country_code = $request->countryCode;
        $phone->label = $request->label;
        $phone->phone_number = $request->phoneNumber;
        $this->authorize('manage', $phone);
        $phone->save();
        return fractal($phone, new PhoneTransformer())
            ->withResourceName('phone')
            ->respond();

    }
public function update ( Request $ request , $ id ) { /** @noinspection PhpUndefinedMethodInspection */ $ request -> validate ( [ "countryCode" => 'required|regex:/\d{1,2}/' , "label" => "required|max:50" , "phoneNumber" => 'required|regex:/\d{10}/' , ] ) ; $ phone = Phone :: findOrFail ( $ id ) ; $ this -> authorize ( 'manage' , $ phone ) ; $ phone -> country_code = $ request -> countryCode ; $ phone -> label = $ request -> label ; $ phone -> phone_number = $ request -> phoneNumber ; $ this -> authorize ( 'manage' , $ phone ) ; $ phone -> save ( ) ; return fractal ( $ phone , new PhoneTransformer ( ) ) -> withResourceName ( 'phone' ) -> respond ( ) ; }
Store an updated Phone
@param  \Illuminate\Http\Request $request current Request object
@param string $id UUID of Phone to update
@return \Illuminate\Http\Response JSON object of updated Phone
Store an updated Phone