Download the PHP package teknyo/laravel-locale-helper without Composer
On this page you can find all versions of the php package teknyo/laravel-locale-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-locale-helper
Laravel Locale Helper
A simple Laravel package providing languages, timezones, currencies, date formats, first-day-of-week management, and number formatting.
Installation
Publish the config:
Usage
-
Using the Facade
-
Using Dependency Injection
-
Languages
-
Timezones
-
Currencies
-
Date Formats
-
First Day of Week
-
Number Formatting
-
Countries
- Phone Numbers
Include/Exclude Usage
-
Config - only expose a few currencies
-
Config - exclude a few languages
-
Config - exclude some timezones
- Config - include/exclude countries and phone Restrict to EU countries only
Exclude specific countries
Runtime Override
If you need to change filters at runtime, you can merge config on the fly:
Or expose a fluent helper on the service:
Quick-Start Blade Example
- Phone Input Integration
This guide explains how to implement a user-friendly phone number input that combines a country code selector with a local number input, ultimately submitting a standardized E.164 formatted phone number to your backend.
- The HTML Structure (Required for both methods) Regardless of which JavaScript method you choose, you need the following HTML structure in your Blade template. The element must include a data-phone-code attribute containing the numeric dialing code, which the JavaScript will use to construct the final E.164 number.
Method 1: Using the @localhelperscripts Blade Directive (Recommended) The package provides a custom Blade directive that automatically injects the necessary JavaScript to handle the input, format the number, and inject a hidden field containing the final E.164 formatted number.
Basic Usage If your HTML elements use the default IDs (phone_country and phone_number), simply add the directive at the bottom of your form or page:
What it does: Listens for changes on the select and input fields. Creates a hidden input named phone (by default). Populates it with the E.164 format (e.g., +12015550123) right before the form submits.
Advanced Usage (Custom IDs & Names) If you have multiple phone inputs on the same page (e.g., Billing and Shipping) or need to change the hidden field name, pass parameters to the directive:
-
Example: Billing Phone
- Example: Shipping Phone
Method 2: Manual Script Injection (Normal Script Way) If you prefer not to use the Blade directive, or if you are working in an environment where Blade directives aren't available (e.g., a standalone Vue/React component or a raw HTML file), you can inject the JavaScript manually.
Basic Implementation Add the following script block to your Blade template, typically inside an @push('scripts') block if you are using a layout that yields scripts at the bottom of the page.
Customizing the Manual Script To use this for a different set of inputs, simply change the constants at the top of the script:
Note: If you have multiple phone inputs on the same page using the manual method, you must duplicate this script block for each input and ensure the IDs and HIDDEN_NAME are unique for each block to avoid conflicts.
Handling the Data in Laravel (Backend) Regardless of which frontend method you use, the form will submit a hidden field containing the fully formatted E.164 phone number. Here is how to handle it in your Laravel Controller:
License
MIT