承接 matteoggl/linnaeus 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

matteoggl/linnaeus

Composer 安装命令:

composer require matteoggl/linnaeus

包简介

A package to create readable, random slugs for Eloquent models from animal names and adjectives.

README 文档

README

GitHub Packagist Downloads

A package to create readable, random slugs for Eloquent models from animal names and adjectives.

Installation

Just require the package through composer:

composer require matteoggl/linnaeus

Usage

Add the HasSlug trait on your Eloquent model and insert a column on it's table named slug, of type string with a unique modifier.

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

By default, a new unique string taken from a combination of 900~ adjectives, 100+ colors and 250~ animals is assigned to the model when created with the following structure: adjective-adjective-animal.

When updated, the slug will not be changed and if soft-deletable, the model's slug will be considered used.

The slugs are used with Laravel's implicit route model binding. For example, this code:

Route::get('/users/{user}', function (App\User $user) {
    return $user->email;
});

will use Linnaeus' slugs (e.g. /users/moldy-encouraging-turtle).

Configuration

To publish the configuration file, run the following command:

php artisan vendor:publish --provider="MatteoGgl\Linnaeus\LinnaeusServiceProvider" --tag="config"

The linnaeus.php configuration file will appear in your config/ directory.

Per-model configuration

Some options can be overridden by updating them inside the model constructor, using a fluent API; here's an example using all the available ones:

public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);
        $this->linnaeus = LinnaeusOptions::create()
            ->withKey('linnaeus_slug')
            ->withStructure(['color', 'animal'])
            ->withSeparator('_')
            ->generatesOnUpdate()
            ->withInvalidAnimals(['aardvark'])
            ->withInvalidAdjectives(['zany'])
            ->withInvalidColors(['blue']);
    }

FAQ

Q: What's up with the name?

A: Take a look at Carl Linnaeus on Wikipedia

Q: Can this package do feature?

A: I created this package out of a need for a personal project. If you have some suggestions feel free to open an issue or a PR! Also, this package is heavily inspired from spatie/laravel-sluggable; maybe the features you are looking for are there.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-08-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固