How to reuse a Form Field?

In using a DRY principle, I want to use Phone input that can be use in all forms. Currently, I've been copy-pasting them accross pages.

TextInput::make('phone')
        ->disableLabel()
        ->label('Phone Number')
        ->placeholder('Phone Number')
        ->validationAttribute('Phone Number')
        ->minLength(10)
        ->maxLength(14)
        ->mask('(999) 999-9999')
        ->stripCharacters(['(', ')', ' ', '-'])
        ->numeric()
        ->rules([ new PhoneNumberRule, 'doesnt_start_with:1'])
        ->required()
        ->validationMessages([
            'doesnt_start_with' => 'Phone Number cannot begin with 1.',
        ]),


So instead of this, is there a way I can use PhoneInput::make('primary_phone') ?
Was this page helpful?