ariaieboy/laravel-persian-helpers
最新稳定版本:2.1.1
Composer 安装命令:
composer require ariaieboy/laravel-persian-helpers
包简介
Add more functionality for Persian language into Laravel
README 文档
README
This package will add some helpers and macros to the laravel that help you work with persian language and convert non persian character and digits to persian or vise-versa.
Requirement
This package requires php version >= 8.4 and laravel version >= 12
Installation
You can install the package via composer:
composer require ariaieboy/laravel-persian-helpers
You can publish the config file with:
php artisan vendor:publish --tag="laravel-persian-helpers-config"
Usage
Facade
PersianHelpers::toEnglishDigit('۱۲۳۴'); // will return "1234" PersianHelpers::toPersianDigit('1234٥٤'); // will return "۱۲۳۴۵۴" PersianHelpers::toPersianLetter(',;كإأؤةۀي?'); // will return "،؛کااوههی؟" PersianHelpers::toPersian('12ي'); // will return "۱۲ی"
Str macros
Str::toEnglishDigit('۱۲۳۴'); // will return "1234" Str::toPersianDigit('1234٥٤'); // will return "۱۲۳۴۵۴" Str::toPersianLetter(',;كإأؤةۀي?'); // will return "،؛کااوههی؟" Str::toPersian('12ي'); // will return "۱۲ی"
Middlewares
By using these middlewares all the user inputs will be converted to correct format.
use Ariaieboy\LaravelPersianHelpers\Http\Middleware\ToEnglishDigit; use Ariaieboy\LaravelPersianHelpers\Http\Middleware\ToPersianDigit; use Ariaieboy\LaravelPersianHelpers\Http\Middleware\ToPersianLetter; use Ariaieboy\LaravelPersianHelpers\Http\Middleware\ToPersian; Route::post('example1')->middleware(ToEnglishDigit::class); Route::post('example2')->middleware(ToPersianDigit::class); Route::post('example3')->middleware(ToPersianLetter::class); Route::post('example4')->middleware(ToPersian::class);
Note: by default
current_password,passwordandpassword_confirmationinputs are ignored and are not affected by this middleware to customize this behavior you should extend each of this middleware and change the$exceptproperty of the middleware
class MyCustomToEnglishDigitMiddleware extends \Ariaieboy\LaravelPersianHelpers\Http\Middleware\ToEnglishDigit{ /** * @var array<string> */ protected array $except = [ 'title', 'password' ]; } Route::post('example')->middleware(MyCustomToEnglishDigitMiddleware::class);
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 1.22k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-19