定制 shaiful/phone-input 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shaiful/phone-input

最新稳定版本:v1.1.5

Composer 安装命令:

composer require shaiful/phone-input

包简介

A Laravel package for phone input with flags and country codes

README 文档

README

This package is used to use ITL Phone input with laravel livewire

Installation

  1. Add the following into composer.json:

    composer require shaiful/phone-input
    
  2. Publish the vendor files

    php artisan vendor:publish --provider="Shaiful\PhoneInput\PhoneInputServiceProvider"
    
  3. Include css tags and js tags into your layout file

    {!! phone_input_css() !!}
    {!! phone_input_js() !!}
    @stack('scripts)
    
  4. Usage

    <x-phone-input model="{livewire_model}" id="{livewire_model}" name="{livewire_model}" class="{any_css_class}" />
    <input type="hidden" wire:model.live="country_code">
    
  5. Example

    <!-- Livewire Component -->
    <div>
     <form wire:submit.prevent="submit">
         <x-phone-input model="phone" id="phone" name="phone" class="block w-full rounded-lg border border-gray-300 bg-gray-50 p-2.5 text-sm text-gray-900 focus:border-blue-500 focus:ring-blue-500" />
         <input type="hidden" wire:model.live="country_code">
         <button type="submit">Submit</button>
     </form>
    </div>
    
    <!-- Livewire Class -->
    use Livewire\Component;
    

class PhoneInputComponent extends Component {

public $phone;
public $country_code;

public function submit()
{
    // Handle the form submission
    $this->validate([
        'phone' => 'required',
        'country_code' => 'required',
    ]);

    // Process the phone number and country code
}

public function render()
{
    return view('livewire.phone-input-component');
}

}


5. If You want to use the input in Spatie Step Wizard, Call this function to reinit on step initialization

init_itl();


统计信息

  • 总下载量: 114
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2025-01-24