定制 daaner/easy-slug 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

daaner/easy-slug

Composer 安装命令:

composer require daaner/easy-slug

包简介

Easy creation of slugs for Laravel 5.4+

README 文档

README

Packagist License Latest Stable Version Total Downloads

Fix

  • fix softDeleted tray

About

[ru] Простое создание уникального слага для Ларавел 5+

[en] Simple creation of a unique slug for Laravel 5+

Установка

composer require daaner/easy-slug

[ru]

  • В шапке модели use EasySlug\EasySlug;
  • В теле модели подключаем трейт use EasySlug;

[en]

  • In header model use EasySlug\EasySlug;
  • In the body of the model use trait use EasySlug;
...
use EasySlug\EasySlug;

class BaseModel extends Model
{

  use EasySlug;
...  

Использование

[ru]

  • Добавляем мутатор в нужную модель (или базовую модель)
  • Первый параметр $value - наше значение
  • Второй параметр slug - поле, в котором хранится наш слаг
  • Третий параметр custom_field - поле из которого будет формироваться слаг
  • Обрезает длину слага до 100 символов

ЗЫ: Если Вы хотите формировать слаг из полей title или name - третий параметр можно не указывать (если находит title формирует сперва из него, если нет - ищет name). Если третий параметр не указан или не найден - формируется слаг 'slug_'. date("Y-m-d-H-i-s"), проверяется на уникальность и, если есть совпадения, дописывает первое уникальное число через дефис.

[en]

  • Add a mutator to the desired model (or base model)
  • The first parameter $value is our value
  • The second parameter slug is the field in which our slug is stored
  • The third parameter custom_field is the field from which the slug will be formed
  • Cuts the length of the slag to 100 characters

PS: If you want to form a slug from the title or name fields - the third parameter can be null (if it finds title forms first of it, if not, it searches for name). If the third parameter is not specified or not found, the slug formed 'slug_'. date("Y-m-d-H-i-s"), is checked for uniqueness and, if there are matches, appends the first unique number with a hyphen.

public function setSlugAttribute($value) {

  $this->EasySlugCheck($value, 'slug', 'custom_field');

}

Контакты

https://t.me/neodaan по всем вопросам

License

EasySlug is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 442
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固