定制 into-the-source/laravel-slugable 二次开发

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

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

into-the-source/laravel-slugable

最新稳定版本:2.0

Composer 安装命令:

composer require into-the-source/laravel-slugable

包简介

A laravel slugable trait

关键字:

README 文档

README

This package will automatic figure out what the slug is going to be based on the title by default
or specified with the slugableColumn variable value that you can specify on your model.

Note: This package will try to never use a old slug, because of SEO friendliness and old links that will link to wrong results.

Usage

Add use Slugable to your model, like the example below:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Intothesource\Slugable\Slugable;

class Page extends Model
{
    use Slugable;
    
    ...

This trait contains a setSlugAttribute method with you only need to trigger from the controller or with a eventListener.
But thats all up to you.

Example

'This is a title' => 'this-is-a-title'

And if you submit the same title agean it will return:

'This is a title' => 'this-is-a-title-2'

If a title ends with a number it will just add the suffix to the existing slug. Example:

'This is my post number 20' => 'this-is-my-post-number-20'

Second time:

'This is my post number 20' => 'this-is-my-post-number-20-2'

Credits

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-11