dudic/laravel-slug-generator
最新稳定版本:1.0.1
Composer 安装命令:
composer require dudic/laravel-slug-generator
包简介
Description
README 文档
README
This package was created to generate slug on my personal projects, it is straightforward to use, you just need to install it, add trait to the model, and set the $slugConfiguration property in your model.
NOTE: Tested for 9.* and 8.* version of Laravel.
Installation
You can install the package via composer:
composer require dudic/laravel-slug-generator
Usage
use Dudic\Sluggable\SlugGenerator; class User extends Authenticatable { use SlugGenerator; // add protected $slugConfiguration = [ 'create_from' => ['first_name', 'last_name'], // ['required', 'array'] 'slug_field' => 'slug', // ['required', 'string'] 'unique' => true, // ['optional', 'bool'] default true, if slug exist unique will add at end '-1' or any next number which will make unique slug 'on_create' => true, // ['optional', 'bool'] default true 'on_update' => true, // ['optional', 'bool'] default true 'separator' => '-', // ['optional', 'string'] default "-" 'max_length' => 250, // ['optional', 'int', 'min:1'] default 250, if not unique can exceed 250 ]; } $user = User::create([ 'first_name' => 'John', 'last_name' => 'Doe' ]); echo $user->slug; // john-doe
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-27