├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── composer.json └── src └── IvanLemeshev └── Laravel5CyrillicSlug ├── Slug.php ├── SlugFacade.php └── SlugServiceProvider.php /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | composer.phar 3 | composer.lock 4 | .DS_Store 5 | .idea 6 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### 1.0.0 (2015-03-01) 2 | 3 | * Initial release 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Ivan Lemeshev 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel 5 Cyrillic Slug 2 | 3 | [![Latest Stable Version](https://poser.pugx.org/ivanlemeshev/laravel5-cyrillic-slug/v/stable.svg)](https://packagist.org/packages/ivanlemeshev/laravel5-cyrillic-slug) [![Total Downloads](https://poser.pugx.org/ivanlemeshev/laravel5-cyrillic-slug/downloads.svg)](https://packagist.org/packages/ivanlemeshev/laravel5-cyrillic-slug) [![Latest Unstable Version](https://poser.pugx.org/ivanlemeshev/laravel5-cyrillic-slug/v/unstable.svg)](https://packagist.org/packages/ivanlemeshev/laravel5-cyrillic-slug) [![License](https://poser.pugx.org/ivanlemeshev/laravel5-cyrillic-slug/license.svg)](https://packagist.org/packages/ivanlemeshev/laravel5-cyrillic-slug) 4 | 5 | ## Supported Alphabets 6 | * Russian 7 | * Kazakh 8 | * Ukrainian 9 | 10 | ## Installation 11 | 12 | You should install this package through Composer. 13 | 14 | Edit your project's `composer.json` file to require `ivanlemeshev/laravel5-cyrillic-slug`. 15 | 16 | "require": { 17 | "ivanlemeshev/laravel5-cyrillic-slug": "1.0.0" 18 | }, 19 | 20 | Next, update Composer from the Terminal: 21 | `composer update` 22 | 23 | Once this operation completes, the final step is to add the service provider. 24 | Open `app/config/app.php`, and add a new item to the providers array. 25 | 26 | `'IvanLemeshev\Laravel5CyrillicSlug\SlugServiceProvider',` 27 | 28 | And add a new item to the aliases array. 29 | 30 | `'Slug' => 'IvanLemeshev\Laravel5CyrillicSlug\SlugFacade',` 31 | 32 | Usage 33 | ------- 34 | Call of the method: `Slug::make($text)` 35 | 36 | Call of the method with specific separator: `Slug::make($text, '_')`. 37 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ivanlemeshev/laravel5-cyrillic-slug", 3 | "description": "Laravael 5 slug maker for Cyrillic strings", 4 | "keywords": ["laravel", "laravel5", "slug", "cyrillic"], 5 | "homepage": "https://github.com/ivanlemeshev/laravel5-cyrillic-slug", 6 | "license": "MIT", 7 | "authors": [ 8 | { 9 | "name": "Ivan Lemeshev", 10 | "email": "vanlmshv@gmail.com", 11 | "role": "Developer" 12 | } 13 | ], 14 | "require": { 15 | "php": ">=5.4.0" 16 | }, 17 | "autoload": { 18 | "psr-0": { 19 | "IvanLemeshev\\Laravel5CyrillicSlug\\": "src/" 20 | } 21 | }, 22 | "minimum-stability": "stable" 23 | } 24 | -------------------------------------------------------------------------------- /src/IvanLemeshev/Laravel5CyrillicSlug/Slug.php: -------------------------------------------------------------------------------- 1 | 'i', 'ц' => 'c', 'у' => 'u', 'к' => 'k', 'е' => 'e', 17 | 'н' => 'n', 'г' => 'g', 'ш' => 'sh', 'щ' => 'shch', 'з' => 'z', 18 | 'х' => 'h', 'ъ' => '', 'ф' => 'f', 'ы' => 'y', 'в' => 'v', 19 | 'а' => 'a', 'п' => 'p', 'р' => 'r', 'о' => 'o', 'л' => 'l', 20 | 'д' => 'd', 'ж' => 'zh', 'э' => 'e', 'ё' => 'e', 'я' => 'ya', 21 | 'ч' => 'ch', 'с' => 's', 'м' => 'm', 'и' => 'i', 'т' => 't', 22 | 'ь' => '', 'б' => 'b', 'ю' => 'yu', 'ү' => 'u', 'қ' => 'k', 23 | 'ғ' => 'g', 'ә' => 'e', 'ң' => 'n', 'ұ' => 'u', 'ө' => 'o', 24 | 'Һ' => 'h', 'һ' => 'h', 'і' => 'i', 'ї' => 'ji', 'є' => 'je', 25 | 'ґ' => 'g', 'Й' => 'I', 'Ц' => 'C', 'У' => 'U', 'Ұ' => 'U', 26 | 'Ө' => 'O', 'К' => 'K', 'Е' => 'E', 'Н' => 'N', 'Г' => 'G', 27 | 'Ш' => 'SH', 'Ә' => 'E', 'Ң '=> 'N', 'З' => 'Z', 'Х' => 'H', 28 | 'Ъ' => '', 'Ф' => 'F', 'Ы' => 'Y', 'В' => 'V', 'А' => 'A', 29 | 'П' => 'P', 'Р' => 'R', 'О' => 'O', 'Л' => 'L', 'Д' => 'D', 30 | 'Ж' => 'ZH', 'Э' => 'E', 'Ё' => 'E', 'Я' => 'YA', 'Ч' => 'CH', 31 | 'С' => 'S', 'М' => 'M', 'И' => 'I', 'Т' => 'T', 'Ь' => '', 32 | 'Б' => 'B', 'Ю' => 'YU', 'Ү' => 'U', 'Қ' => 'K', 'Ғ' => 'G', 33 | 'Щ' => 'SHCH', 'І' => 'I', 'Ї' => 'YI', 'Є' => 'YE', 'Ґ' => 'G', 34 | ]; 35 | 36 | foreach ($matrix as $from => $to) { 37 | $title = mb_eregi_replace($from, $to, $title); 38 | } 39 | 40 | $pattern = '![^'.preg_quote($separator).'\pL\pN\s]+!u'; 41 | $title = preg_replace($pattern, '', mb_strtolower($title)); 42 | 43 | $flip = $separator == '-' ? '_' : '-'; 44 | 45 | $title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title); 46 | $title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title); 47 | 48 | return trim($title, $separator); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/IvanLemeshev/Laravel5CyrillicSlug/SlugFacade.php: -------------------------------------------------------------------------------- 1 | app->bind('slug', function() { 15 | return new Slug; 16 | }); 17 | } 18 | } 19 | --------------------------------------------------------------------------------