0.8.3
0.8.3.0Russian SEO friendly slugs
MIT
The Requires
by Alexey Mezenin
laravel url google seo russian yandex cyrillic slug
Wallogit.com
2017 © Pedro Peláez
Russian SEO friendly slugs for Laravel 5
The package is not supported anymore, (*1)
This package offers easy to use cyrillic slugs like 'Как_вырастить_дерево' and Yandex transliterated 'kak-vyrastis-derevo' slugs and their variations with lowercased letters and different separators., (*2)
Start with editing your Laravel project's composer.json file, add this line to the require section:, (*4)
"require": {
....
"alexeymezenin/laravel-russian-slugs": "0.9.*"
After that run this command to install package:, (*5)
composer update
Now, insert these two lines into provider and aliases arrays in config/app.php:, (*6)
'providers' => [
....
AlexeyMezenin\LaravelRussianSlugs\SlugsServiceProvider::class,
'aliases' => [
....
'Slug' => AlexeyMezenin\LaravelRussianSlugs\SlugsFacade::class,
Finally, you need to register config file and slugs-related commands by running:, (*7)
php artisan vendor:publish
To use package, you need to update your models with thisuse clause:, (*9)
class Articles extends Model
{
use \AlexeyMezenin\LaravelRussianSlugs\SlugsTrait;
Then you need to create slug column in a migration:, (*10)
$table->string('slug');
To use auto slug creation feature add slugFrom property to your model:, (*11)
protected $slugFrom = 'article_name';
In this case, every time when you're saving data to a DB, package tries to create (but not recreate) a new slug and save it:, (*12)
$article = Article::create(['article_name' => 'Как вырастить дерево?']);
Of course, that doesn't work with mass inserts and updates when you're updating multiple rows with one query., (*13)
To create new record with a slug use reslug() method. This will add slug, based on name column:, (*15)
$article = new Article;
$article->name = 'How to grow a tree?';
$article->reslug('name');
$article->save();
You can update existing record and add a slug:, (*16)
$article = Article::find(1);
$article->reslug('name');
$article->save();
If slug already exists, but you need to recreate it, use forced reslug:, (*17)
$article->reslug('name', true);
Alternatively, you can use Slug facade to manually work with slugs:, (*18)
$article = Article::find(1);
$article->update([
'slug' => Slug::build($article->name)
]);
findBySlug() method allows you to find a model by it's slug:, (*19)
$slug = 'how-to-grow-a-tree'; $article = Article::findBySlug($slug); echo $article->name; // Will output "How to grow a tree?"
To configure a package you should edit config/seoslugs.php file., (*21)
delimiter is a symbol which replaces all spaces in a string. By default it's '_', but also can be '-'., (*22)
urlType is a type of slug:, (*23)
Default is 1. Used for URLs like /категория/книги_в_москве, (*24)
2 is for traslitterated URLs like /kategoriya/knigi_v_moskve, Yandex rules used to transliterate URL., (*25)
keepCapitals is false by default. When true it keeps capital letters in a slug, for example: /книги_в_Москве, (*26)
slugColumnName sets the name of a slug column. slug by default., (*27)
There are three console commands available in the package:, (*29)
php artisan slug:auto {table} {column} command creates and executes migration, reslugs a table (creates slugs for all rows) using {column} as source., (*30)
php artisan slug:migration {table} command creates migration to add a slug column., (*31)
php artisan slug:reslug {table} {column} command creates or recreates slugs for a specified table., (*32)
Commands slug:auto and slug:reslug will recreate all slugs, even if they are already exist (forced reslug used)., (*33)
RussianSeoSlugs was written by Alexey Mezenin and released under the MIT License., (*34)
Russian SEO friendly slugs
MIT
laravel url google seo russian yandex cyrillic slug