Php Laravel验证-多个字段唯一
是否有方法基于多个字段同时唯一来验证唯一的Php Laravel验证-多个字段唯一,php,validation,laravel,Php,Validation,Laravel,是否有方法基于多个字段同时唯一来验证唯一的$data 我有一个表schedule,其中包含以下Schema <?php Schema::create('schedules', function(Blueprint $table) { $table->increments('id'); $table->integer('user_id', false, true); $table->integer('client_id', f
$data
我有一个表schedule
,其中包含以下Schema
<?php
Schema::create('schedules', function(Blueprint $table) {
$table->increments('id');
$table->integer('user_id', false, true);
$table->integer('client_id', false, true);
$table->integer('day', false, true);
$table->integer('month', false, true);
$table->integer('year', false, true);
$table->enum('type', array('template', 'revision', 'common'));
$table->string('name', 50)->default('Untitled Template');
$table->boolean('is_published');
$table->timestamp('published_at');
$table->softDeletes();
$table->timestamps();
});
?>
对于我来说,对于给定的天
,月
,年
,只能有一个通用
类型计划。同一日期可以有无限多个版本
,但是一次只能有一个is_published=false
版本
<代码>模板忽略日期(无论您输入什么,它们都将始终设置为零)
我无法想象如何应用,因为只有当类型='common'
时,我的日
,月
,年
才应该是唯一的
这是否太抽象,无法与验证器一起使用,我是否应该手动搜索现有条目?看看我更新的问题。你能看一下吗?那很复杂。可能会有帮助,否则自定义验证可能是一种方法。