kduma/eloquent-sluggable 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

kduma/eloquent-sluggable

最新稳定版本:v2.3.0

Composer 安装命令:

composer require kduma/eloquent-sluggable

包简介

Eases using and generating slugs Laravel Eloquent models.

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License SensioLabsInsight StyleCI Build Status

Eases using and generating slugs Laravel Eloquent models.

Check full documentation here: opensource.duma.sh/libraries/php/eloquent-sluggable

Setup

Add the package to the require section of your composer.json and run composer update

"kduma/eloquent-sluggable": "^1.1"

Prepare models

Inside your model (not on top of file) add following lines:

use \KDuma\Eloquent\Slugabble;

Optionally you can add also SluggableString function which will return string from which slug will be made (default it uses title field):

protected function SluggableString(){
    return $this->year.' '.$this->title;
}  

In database create slug string field. If you use migrations, you can use following snippet:

$table->string('slug')->unique();

Usage

By default it generates slug on first save.

  • $model->newSlug() - Generate new slug. (Remember to save it by yourself)
  • Model::whereSlug($slug)->first() - Find by slug. (whereSlug is query scope)

Eric L. Barnes

A special thanks to Eric L. Barnes, an original code creator that this package is based on.

Packagist

View this package on Packagist.org: kduma/eloquent-sluggable

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-31