├── .phpunit.cache └── test-results ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── composer.json ├── composer.lock ├── phpstan.neon ├── phpunit.xml ├── resources └── lang │ ├── ar │ └── arPhpLaravel.php │ └── en │ └── arPhpLaravel.php └── src ├── ArPhpLaravel.php ├── ArPhpLaravelFacade.php ├── ArPhpLaravelServiceProvider.php ├── Macroables.php └── SearchAr.php /.phpunit.cache/test-results: -------------------------------------------------------------------------------- 1 | {"version":1,"defects":[],"times":{"StillCode\\ArPhpLaravel\\Tests\\ExampleTest::true_is_true":0.014,"StillCode\\ArPhpLaravel\\Tests\\arPhpTest::it_is_not_arabic_text":0.004,"StillCode\\ArPhpLaravel\\Tests\\arPhpTest::it_is_arabic_text":0.001,"StillCode\\ArPhpLaravel\\Tests\\arPhpTest::int2str_convert_number_to_text":0.002,"StillCode\\ArPhpLaravel\\Tests\\arPhpTest::int2str_cant_convert_text_to_number":0.003,"StillCode\\ArPhpLaravel\\Tests\\arPhpTest::str2int_convert_text_to_number":0.001,"StillCode\\ArPhpLaravel\\Tests\\arPhpTest::str2int_cant_convert_number_to_text":0.001,"StillCode\\ArPhpLaravel\\Tests\\arPhpTest::check_is_not_female":0.001,"StillCode\\ArPhpLaravel\\Tests\\arPhpTest::check_is_female":0.001,"StillCode\\ArPhpLaravel\\Tests\\arPhpTest::guess_gender_male":0.002,"StillCode\\ArPhpLaravel\\Tests\\arPhpTest::guess_gender_female":0.001,"StillCode\\ArPhpLaravel\\Tests\\arPhpTest::it_convert_mony_to_text":0.001,"StillCode\\ArPhpLaravel\\Tests\\arPhpTest::it_can_translate_text":0.001}} -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `ar-php-laravel` will be documented in this file 4 | 5 | ## 2.0.4 - 2025-03-02 6 | 7 | ### What's Changed 8 | 9 | * Bump aglipanci/laravel-pint-action from 2.3.1 to 2.4 by @dependabot in https://github.com/still-code/ar-php-laravel/pull/38 10 | * Bump dependabot/fetch-metadata from 2.0.0 to 2.1.0 by @dependabot in https://github.com/still-code/ar-php-laravel/pull/39 11 | * Bump dependabot/fetch-metadata from 2.1.0 to 2.2.0 by @dependabot in https://github.com/still-code/ar-php-laravel/pull/42 12 | * Bump dependabot/fetch-metadata from 2.2.0 to 2.3.0 by @dependabot in https://github.com/still-code/ar-php-laravel/pull/43 13 | * Bump aglipanci/laravel-pint-action from 2.4 to 2.5 by @dependabot in https://github.com/still-code/ar-php-laravel/pull/44 14 | * support laravel 12 by @atmonshi in https://github.com/still-code/ar-php-laravel/pull/45 15 | 16 | **Full Changelog**: https://github.com/still-code/ar-php-laravel/compare/2.0.3...2.0.4 17 | 18 | ## 2.0.3 - 2024-04-02 19 | 20 | ### What's Changed 21 | 22 | * Update README.md by @Smailancer in https://github.com/still-code/ar-php-laravel/pull/33 23 | * Bump aglipanci/laravel-pint-action from 2.3.0 to 2.3.1 by @dependabot in https://github.com/still-code/ar-php-laravel/pull/34 24 | * Bump ramsey/composer-install from 2 to 3 by @dependabot in https://github.com/still-code/ar-php-laravel/pull/35 25 | * Bump dependabot/fetch-metadata from 1.6.0 to 2.0.0 by @dependabot in https://github.com/still-code/ar-php-laravel/pull/36 26 | * [Upgrade] Added support for Laravel 11 by @GoodM4ven in https://github.com/still-code/ar-php-laravel/pull/37 27 | 28 | ### New Contributors 29 | 30 | * @Smailancer made their first contribution in https://github.com/still-code/ar-php-laravel/pull/33 31 | * @GoodM4ven made their first contribution in https://github.com/still-code/ar-php-laravel/pull/37 32 | 33 | **Full Changelog**: https://github.com/still-code/ar-php-laravel/compare/2.0.2...2.0.3 34 | 35 | ## 2.0.2 - 2023-11-07 36 | 37 | ### What's Changed 38 | 39 | - Updates by @atmonshi in https://github.com/still-code/ar-php-laravel/pull/25 40 | - Bump dependabot/fetch-metadata from 1.3.6 to 1.4.0 by @dependabot in https://github.com/still-code/ar-php-laravel/pull/26 41 | - Bump aglipanci/laravel-pint-action from 2.2.0 to 2.3.0 by @dependabot in https://github.com/still-code/ar-php-laravel/pull/27 42 | - Bump dependabot/fetch-metadata from 1.4.0 to 1.5.1 by @dependabot in https://github.com/still-code/ar-php-laravel/pull/28 43 | - Bump dependabot/fetch-metadata from 1.5.1 to 1.6.0 by @dependabot in https://github.com/still-code/ar-php-laravel/pull/29 44 | - Bump stefanzweifel/git-auto-commit-action from 4 to 5 by @dependabot in https://github.com/still-code/ar-php-laravel/pull/31 45 | - Bump actions/checkout from 3 to 4 by @dependabot in https://github.com/still-code/ar-php-laravel/pull/30 46 | - add support for php 8.2 by @atmonshi in https://github.com/still-code/ar-php-laravel/pull/32 47 | 48 | ### New Contributors 49 | 50 | - @dependabot made their first contribution in https://github.com/still-code/ar-php-laravel/pull/26 51 | 52 | **Full Changelog**: https://github.com/still-code/ar-php-laravel/compare/2.0.1...2.0.2 53 | 54 | ## 2.0.1 - 2023-04-15 55 | 56 | ### What's Changed 57 | 58 | - updates by @atmonshi in https://github.com/still-code/ar-php-laravel/pull/24 59 | 60 | **Full Changelog**: https://github.com/still-code/ar-php-laravel/compare/2.0.0...2.0.1 61 | 62 | ## 2.0.0 - 2023-04-15 63 | 64 | ### What's Changed 65 | 66 | - support laravel 10 by @atmonshi in https://github.com/still-code/ar-php-laravel/pull/21 67 | - change the namespace from AtmCode to StillCode by @atmonshi in https://github.com/still-code/ar-php-laravel/pull/22 68 | - Apply fixes from StyleCI by @atmonshi in https://github.com/still-code/ar-php-laravel/pull/23 69 | 70 | **Full Changelog**: https://github.com/still-code/ar-php-laravel/compare/1.7.0...1.8.0 71 | 72 | ## 1.5.0 - 2022-01-31 73 | 74 | - add `translate` function, useful for slug generating 75 | 76 | ## 1.4.0 - 2021-08-17 77 | 78 | - add support for php 8.0, thanks to @koossaayy 79 | - pump [ar-php](https://github.com/khaled-alshamaa/ar-php) version to 6.2 80 | 81 | ## 1.3.1 - 2021-05-11 82 | 83 | - pump ar-php to version 6.1 84 | 85 | ## 1.3.0 - 2021-05-08 86 | 87 | - remove `trait SearchAr` in favor of using macrables 88 | - adding macros for Query Builder and Eloquent Builder 89 | 90 | ## 1.2.0 - 2021-05-04 91 | 92 | - support the function utf8Glyphs 93 | 94 | ## 1.1.0 - 2021-01-19 95 | 96 | - add the trait for Eloquent to search directly in Arabic 97 | 98 | ## 1.0.0 - 2021-04-06 99 | 100 | - the initial release of the library AR-PHP for laravel 101 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | Please read and understand the contribution guide before creating an issue or pull request. 6 | 7 | ## Etiquette 8 | 9 | This project is open source, and as such, the maintainers give their free time to build and maintain the source code 10 | held within. They make the code freely available in the hope that it will be of use to other developers. It would be 11 | extremely unfair for them to suffer abuse or anger for their hard work. 12 | 13 | Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the 14 | world that developers are civilized and selfless people. 15 | 16 | It's the duty of the maintainer to ensure that all submissions to the project are of sufficient 17 | quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. 18 | 19 | ## Viability 20 | 21 | When requesting or submitting new features, first consider whether it might be useful to others. Open 22 | source projects are used by many developers, who may have entirely different needs to your own. Think about 23 | whether or not your feature is likely to be used by other users of the project. 24 | 25 | ## Procedure 26 | 27 | Before filing an issue: 28 | 29 | - Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. 30 | - Check to make sure your feature suggestion isn't already present within the project. 31 | - Check the pull requests tab to ensure that the bug doesn't have a fix in progress. 32 | - Check the pull requests tab to ensure that the feature isn't already in progress. 33 | 34 | Before submitting a pull request: 35 | 36 | - Check the codebase to ensure that your feature doesn't already exist. 37 | - Check the pull requests to ensure that another person hasn't already submitted the feature or fix. 38 | 39 | ## Requirements 40 | 41 | If the project maintainer has any additional requirements, you will find them listed here. 42 | 43 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). 44 | 45 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 46 | 47 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 48 | 49 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. 50 | 51 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 52 | 53 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 54 | 55 | **Happy coding**! 56 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Ashraf Monshi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | 6 | 7 | 8 | 9 |

10 | 11 | # laravel package for the Ar-PHP Project 12 | 13 | this is just a wrapper to use with laravel for the Ar-PHP Library, for more details checkout [khaled-alshamaa: ar-php](https://github.com/khaled-alshamaa/ar-php) 14 | ## Installation 15 | You can install the package via composer: 16 | ```bash 17 | composer require still-code/ar-php-laravel 18 | ``` 19 | 20 | ## Available functions 21 | #### Spell Numbers in the Arabic Idiom 22 | ``` php 23 | dump(ArPhpLaravel::int2str(123)); // مئة و ثلاثة و عشرون 24 | dump(ArPhpLaravel::str2int('مئة و ثلاثة و عشرون')); // 123 25 | ``` 26 | 27 | #### English-Arabic Transliteration 28 | ``` php 29 | dump(ArPhpLaravel::en2ar('google')); // غوغل 30 | dump(ArPhpLaravel::ar2en('خالِد الشَمعَة')); // Khalid Ash-Sham'ah 31 | ``` 32 | 33 | #### Arabic Gender Guesser 34 | Check the Gender 35 | ``` php 36 | dump(ArPhpLaravel::isFemale('محمد')); // false 37 | ``` 38 | get the gender as string 39 | ``` php 40 | dump(ArPhpLaravel::guessGender('محمد')); // Male 41 | ``` 42 | 43 | #### Parse any Arabic textual datetime description into timestamp 44 | ``` php 45 | dump(ArPhpLaravel::strtotime('الخميس القادم', time(), 'l dS F Y')); // Thursday 13th May 2021 46 | ``` 47 | 48 | #### Arabic Sentiment Analysis 49 | ``` php 50 | dump(ArPhpLaravel::arSentiment(TEXT)); 51 | ``` 52 | 53 | #### Arabic Text Standardize 54 | ``` php 55 | dump(ArPhpLaravel::standard(TEXT)); 56 | ``` 57 | 58 | #### Arabic Auto Summarize 59 | ``` php 60 | dump(ArPhpLaravel::arSummary(TEXT)); 61 | ``` 62 | 63 | #### Convert Money to string 64 | ``` php 65 | dump(ArPhpLaravel::money2str(123, 'SAR', 'ar')); // مئة و ثلاثة و عشرون ريالا 66 | dump(ArPhpLaravel::money2str(123, 'SAR', 'en')); // 123 Riyal 67 | dump(ArPhpLaravel::money2str(123, 'EGP', 'ar')); // مئة و ثلاثة و عشرون جنيها 68 | ``` 69 | 70 | #### Spell Numbers in the Arabic Idiom 71 | ``` php 72 | dump(ArPhpLaravel::int2indic(123)); // ١٢٣ 73 | ``` 74 | 75 | #### Arabic Glyphs to Render Arabic Text 76 | ``` php 77 | dump(ArPhpLaravel::utf8Glyphs(1229)); 78 | ``` 79 | 80 | #### translate arabic text to english, useful for slug generating 81 | ``` php 82 | dump(ArPhpLaravel::translate('اهلا بالكل')); // Ahla Balkl 83 | ``` 84 | 85 | ### Search with Eloquent and query Builder 86 | Using search for arabic letters with Eloquent Builder 87 | ```php 88 | Model::searchAr('فلسطين','content')->get(); 89 | ``` 90 | 91 | 92 | you can use the same with Query Builder: 93 | ```php 94 | DB::table('table_name')->searchAr('فلسطين','content')->get(); 95 | ``` 96 | 97 | 98 | you can set the search mode `OR` (default) or `AND` 99 | ```php 100 | DB::table('table_name')->searchAr('فلسطين','content','OR')->get(); 101 | ``` 102 | 103 | 104 | and it will find result for any of the words: 105 | >فلسطينيون فلسطيني فلسطينية فلسطينيتين فلسطينيين فلسطينيان فلسطينيات فلسطينيوا 106 | 107 | you can also sort the results by using: 108 | ```php 109 | DB::table('table_name')->orderAr('فلسطين','content')->get(); 110 | ``` 111 | 112 | ## Testing 113 | ``` bash 114 | composer test 115 | ``` 116 | 117 | ## Changelog 118 | Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. 119 | 120 | ## Contributing 121 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 122 | 123 | ## Credits 124 | - [Khaled Alshamaa](https://github.com/khaled-alshamaa) 125 | - [All Contributors](../../contributors) 126 | 127 | ## Todo 128 | - write more tests 129 | - add more functions from the main package 130 | - add helpers for the Facade 131 | 132 | ## License 133 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 134 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "still-code/ar-php-laravel", 3 | "description": "ar-php-laravel", 4 | "keywords": [ 5 | "still-code", 6 | "ar-php-laravel", 7 | "laravel", 8 | "Arabic", 9 | "arabic-sentiment", 10 | "arabic-numbers", 11 | "arabic-glyphs", 12 | "arabic-calendar", 13 | "arabic-sql-query", 14 | "arabic-segments-identifier" 15 | ], 16 | "homepage": "https://github.com/still-code/ar-php-laravel", 17 | "license": "MIT", 18 | "type": "library", 19 | "authors": [ 20 | { 21 | "name": "Ashraf Monshi", 22 | "email": "wh7r.com@gmail.com", 23 | "role": "Developer" 24 | } 25 | ], 26 | "require": { 27 | "php": "^7.1|^8.0|^8.1|^8.2", 28 | "illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0", 29 | "khaled.alshamaa/ar-php": "^6.3" 30 | }, 31 | "require-dev": { 32 | "laravel/pint": "^1.8", 33 | "nunomaduro/larastan": "^2.0", 34 | "orchestra/testbench": "^7.0|^8.0|^9.0|^10.0", 35 | "phpunit/phpunit": "^9.5|^10.1|^11.1" 36 | }, 37 | "autoload": { 38 | "psr-4": { 39 | "StillCode\\ArPhpLaravel\\": "src" 40 | } 41 | }, 42 | "autoload-dev": { 43 | "psr-4": { 44 | "StillCode\\ArPhpLaravel\\Tests\\": "tests" 45 | } 46 | }, 47 | "scripts": { 48 | "test": "vendor/bin/phpunit", 49 | "test-coverage": "vendor/bin/phpunit --coverage-html coverage" 50 | }, 51 | "config": { 52 | "sort-packages": true 53 | }, 54 | "extra": { 55 | "laravel": { 56 | "providers": [ 57 | "StillCode\\ArPhpLaravel\\ArPhpLaravelServiceProvider" 58 | ], 59 | "aliases": { 60 | "ArPhpLaravel": "StillCode\\ArPhpLaravel\\ArPhpLaravelFacade" 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /phpstan.neon: -------------------------------------------------------------------------------- 1 | includes: 2 | - ./vendor/nunomaduro/larastan/extension.neon 3 | 4 | parameters: 5 | 6 | paths: 7 | - src 8 | 9 | # Level 9 is the highest level 10 | level: 5 11 | 12 | # ignoreErrors: 13 | # - '#PHPDoc tag @var#' 14 | 15 | excludePaths: 16 | - vendor 17 | 18 | # checkMissingIterableValueType: false 19 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ./tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ./src 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /resources/lang/ar/arPhpLaravel.php: -------------------------------------------------------------------------------- 1 | 'ايجابي', 5 | 'negative' => 'سلبي', 6 | 'female' => 'مؤنث', 7 | 'male' => 'ذكر', 8 | ]; 9 | -------------------------------------------------------------------------------- /resources/lang/en/arPhpLaravel.php: -------------------------------------------------------------------------------- 1 | 'Positive', 5 | 'negative' => 'Negative', 6 | 'female' => 'Female', 7 | 'male' => 'Male', 8 | ]; 9 | -------------------------------------------------------------------------------- /src/ArPhpLaravel.php: -------------------------------------------------------------------------------- 1 | isArabic($text); 15 | } 16 | 17 | public static function int2str($integer, $numberFeminine = 1, $numberFormat = 1, $setNumberOrder = null) 18 | { 19 | self::Arabic()->setNumberFeminine($numberFeminine); 20 | self::Arabic()->setNumberFormat($numberFormat); 21 | if ($setNumberOrder !== null) { 22 | self::Arabic()->setNumberOrder($setNumberOrder); 23 | } 24 | 25 | return self::Arabic()->int2str($integer); 26 | } 27 | 28 | public static function str2int($number) 29 | { 30 | return self::Arabic()->str2int($number); 31 | } 32 | 33 | public static function arSentiment($text) 34 | { 35 | return (self::Arabic()->arSentiment($text) > 0) 36 | ? __('arPhpLaravel::arPhpLaravel.positive') 37 | : __('arPhpLaravel::arPhpLaravel.negative'); 38 | } 39 | 40 | public static function en2ar($text) 41 | { 42 | return self::Arabic()->en2ar($text); 43 | } 44 | 45 | public static function ar2en($text) 46 | { 47 | return self::Arabic()->ar2en($text); 48 | } 49 | 50 | public static function isFemale($text) 51 | { 52 | return self::Arabic()->isFemale($text); 53 | } 54 | 55 | public static function guessGender($text) 56 | { 57 | return (self::Arabic()->isFemale($text) === true) 58 | ? __('arPhpLaravel::arPhpLaravel.female') 59 | : __('arPhpLaravel::arPhpLaravel.male'); 60 | } 61 | 62 | public static function strtotime($text, $time, $format = 'l dS F Y') 63 | { 64 | $int = self::Arabic()->strtotime($text, $time); 65 | 66 | return date($format, $int); 67 | } 68 | 69 | public static function standard($text) 70 | { 71 | return self::Arabic()->standard($text); 72 | } 73 | 74 | public static function arSummary($text, $keywords, $int, $mode, $output, $style = null) 75 | { 76 | return self::Arabic()->arSummary($text, $keywords, $int, $mode, $output, $style); 77 | } 78 | 79 | public static function money2str($number, $iso = 'SAR', $lang = 'ar') 80 | { 81 | return self::Arabic()->money2str($number, $iso, $lang); 82 | } 83 | 84 | public static function int2indic($number) 85 | { 86 | return self::Arabic()->int2indic($number); 87 | } 88 | 89 | public static function utf8Glyphs($text) 90 | { 91 | return self::Arabic()->utf8Glyphs($text); 92 | } 93 | 94 | public static function plural($singular, $count, $plural2 = null, $plural3 = null, $plural4 = null) 95 | { 96 | $text = self::Arabic()->arPlural($singular, $count, $plural2, $plural3, $plural4); 97 | 98 | return str_replace('%d', $count, $text); 99 | } 100 | 101 | public static function translate($text) 102 | { 103 | return self::Arabic()->ar2en($text); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/ArPhpLaravelFacade.php: -------------------------------------------------------------------------------- 1 | loadTranslationsFrom(__DIR__.'/../resources/lang', 'arPhpLaravel'); 17 | } 18 | 19 | /** 20 | * Register the application services. 21 | */ 22 | public function register() 23 | { 24 | // Register the main class to use with the facade 25 | $this->app->singleton('ar-php-laravel', function () { 26 | return new ArPhpLaravel(); 27 | }); 28 | 29 | /** 30 | * Query Builder Macro for search where in arabic letters. 31 | */ 32 | Builder::macro('searchAr', function ($search, $field, $mode = 'OR') { 33 | return Macroables::setSearchWheres($this, $search, $field, $mode); 34 | }); 35 | 36 | /** 37 | * Query Builder Macro for order by arabic letters. 38 | */ 39 | Builder::macro('orderAr', function ($search, $field) { 40 | return Macroables::setSearchOrder($this, $search, $field); 41 | }); 42 | 43 | /** 44 | * Eloquent Builder Macro for search where in arabic letters. 45 | */ 46 | EloquentBuilder::macro('searchAr', function ($search, $field, $mode = 'OR') { 47 | return Macroables::setSearchWheres($this, $search, $field, $mode); 48 | }); 49 | 50 | /** 51 | * Eloquent Builder Macro for order by arabic letters. 52 | */ 53 | EloquentBuilder::macro('orderAr', function ($search, $field) { 54 | return Macroables::setSearchOrder($this, $search, $field); 55 | }); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Macroables.php: -------------------------------------------------------------------------------- 1 | setQueryStrFields($field); 11 | $setMode = ($mode === 'AND') ? 1 : 0; 12 | $Arabic->setQueryMode($setMode); 13 | $strCondition = $Arabic->arQueryWhereCondition($search); 14 | 15 | return $query->whereRaw($strCondition); 16 | } 17 | 18 | public static function setSearchOrder($query, $search, $field) 19 | { 20 | $Arabic = new \ArPHP\I18N\Arabic(); 21 | $Arabic->setQueryStrFields($field); 22 | $strCondition = $Arabic->arQueryOrderBy($search); 23 | 24 | return $query->orderByRaw($strCondition); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/SearchAr.php: -------------------------------------------------------------------------------- 1 | setQueryStrFields($field); 11 | $Arabic->setQueryMode(1); 12 | $strCondition = $Arabic->arQueryWhereCondition($search); 13 | 14 | $query->whereRaw($strCondition); 15 | 16 | return $query; 17 | } 18 | } 19 | --------------------------------------------------------------------------------