承接 topview-digital/laravel-unique-json-rule 相关项目开发

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

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

topview-digital/laravel-unique-json-rule

Composer 安装命令:

composer require topview-digital/laravel-unique-json-rule

包简介

README 文档

README

GitHub release Scrutinizer Code Quality Build Status Code Intelligence Status License Total Downloads HitCount

Laravel Unique Json

Check if a record value in a JSON column is unique in the database.

Implementations of Json field unqiue validation rule and inspired by codezero-be/laravel-unique-translation

Requirements

  • PHP >= 7.0
  • MySQL >= 5.7
  • Laravel >= 5.6

Installation

Require the package via Composer:

composer require topview-digital/laravel-unique-json-rule

Laravel will automatically register the ServiceProvider.

Usage

For the following examples

Validate an Array of Contacts

Your form can also submit an array of contact.

<input name="contact[name]">
<input name="contact[email]">
<input name="contact[phone]">

We need to validate the entire array in this case.

$attributes = request()->validate([
    'contact.name' => 'unique_json:clients,contact->name',
    'contact.email' => UniqueJsonRule::for('clients','contact->email'),
]);

Ignore a Record with ID

If you're updating a record, you may want to ignore the post itself from the unique check.

$attributes = request()->validate([
    'contact.name' => 'unique_json:clients,contact->name,{$client->id}',
    'contact.email' => UniqueJsonRule::for('clients','contact->email')->ignore($client->id),
]);

Ignore Records with a Specific Column and Value

If your ID column has a different name, or you just want to use another column:

$attributes = request()->validate([
    'contact.name' => 'unique_json:clients,contact->name,{$client->uuid},uuid',
    'contact.email' => UniqueJsonRule::for('clients','contact->email')->ignore($client->uuid,'uuid'),
]);

Error Messages

You can pass your own error message with any of the following keys. The first one found will be used.

$attributes = request()->validate([
    'contact.name' => 'unique_json:clients,contact->name,{$client->id}',
], [
    'contact.name.unique_json' => 'Your custom :attribute error.',
]);

Changelog

See a list of important changes in the changelog.

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固