PHP code example of ariaieboy / laravel-persian-helpers

1. Go to this page and download the library: Download ariaieboy/laravel-persian-helpers library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ariaieboy / laravel-persian-helpers example snippets


    PersianHelpers::toEnglishDigit('۱۲۳۴'); // will return "1234"

    PersianHelpers::toPersianDigit('1234٥٤'); // will return "۱۲۳۴۵۴"

    PersianHelpers::toPersianLetter(',;كإأؤةۀي?'); // will return "،؛کااوههی؟"
    
    PersianHelpers::toPersian('12ي'); // will return "۱۲ی"

    Str::toEnglishDigit('۱۲۳۴'); // will return "1234"

    Str::toPersianDigit('1234٥٤'); // will return "۱۲۳۴۵۴"

    Str::toPersianLetter(',;كإأؤةۀي?'); // will return "،؛کااوههی؟"
    
    Str::toPersian('12ي'); // will return "۱۲ی"

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);

class MyCustomToEnglishDigitMiddleware extends \Ariaieboy\LaravelPersianHelpers\Http\Middleware\ToEnglishDigit{
    /**
    * @var array<string> 
    */
    protected array $except = [
    'title',
    'password'
];
}

Route::post('example')->middleware(MyCustomToEnglishDigitMiddleware::class);
bash
php artisan vendor:publish --tag="laravel-persian-helpers-config"