定制 cserobiul/slug 二次开发

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

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

cserobiul/slug

最新稳定版本:v1.1.3

Composer 安装命令:

composer require cserobiul/slug

包简介

Simple and Easy Laravel Unicode Supported Unique Slug Generator Package

README 文档

README

Very Simple and Easy Package

Installation

composer require cserobiul/slug

Configuration

No Configuration Need

Use from Controller

Import Slug class

use Cserobiul\Slug\Slug;

Publish configuration

php artisan vendor:publish cserobiul/slug

Example #01- Blog unique slug from 'Blog Title'

Suppose, we already have blogs table and added an slug column which is unique. Now, if we passed title and generate unique slug from that.

// 1st time create slug 
Slug::make('blogs', 'Blog Title', 'slug');
// Output: blog-title

// 2nd time create slug 
Slug::make('blogs', 'Blog Title', 'slug');
// Output: blog-title-1

// 3rd time create slug 
Slug::make('blogs', 'Blog Title', 'slug');
// Output: blog-title-2

// 4th time create slug 
Slug::make('blogs', 'Blog Title', 'slug');
// Output: blog-title-3

Example #02- Blog 'Unicode Title' to unique slug

// 1st time create slug 
Slug::make('blogs', 'প্রেমের নাম বেদনা', 'slug');
// Output: প্রেমের-নাম-বেদনা

// 2nd time create slug 
Slug::make('blogs', 'প্রেমের নাম বেদনা', 'slug');
// Output: প্রেমের-নাম-বেদনা-1

// 3rd time create slug 
Slug::make('blogs', 'প্রেমের নাম বেদনা', 'slug');
// Output: প্রেমের-নাম-বেদনা-2

// 4th time create slug 
Slug::make('blogs', 'প্রেমের নাম বেদনা', 'slug');
// Output: প্রেমের-নাম-বেদনা-3

Example #03 - Pass custom separator for Customer Table

Suppose separator is _ underscore.

// 1st time create customer username.
UniqueSlug::make('customers', 'jony', 'username', '_'); 
// Output: jony

// 2nd time create customer username.
UniqueSlug::make('customers', 'jony', 'username', '_');
// Output: jony_1

// 3rd time create customer username.
UniqueSlug::make('customers', 'jony', 'username', '_');
// Output: jony_2

// 4th time create customer username.
UniqueSlug::make('customers', 'jony', 'username', '_'); 
// Output: jony_3

Contribution

Anyone can create any Pull request.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固