gpt4 book ai didi

mysql - 消息: "Method Illuminate\Validation\Validator::validateTazker does not exist."

转载 作者:行者123 更新时间:2023-11-29 09:32:44 26 4
gpt4 key购买 nike

我尝试为两列设置唯一验证,其中一列是 BadgeCode,另一列是 Tazkera,但我收到以下错误,但对于其余列,验证工作正常:

Error:

Method Illuminate\Validation\Validator::validateTazker does not exist.
Method Illuminate\Validation\Validator::validateBadgeCode does not exist.

迁移代码适用于员工表:

public function up()
{
Schema::create('employees', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('BadgeCode')->unique();
$table->string('BadgeType');
$table->integer('company_id');
$table->integer('nationality_id');
$table->string('lastname');
$table->string('firstname');
$table->string('tazker')->unique();
$table->string('telphonenumber');
$table->string('position');
$table->string('supervisorname');
$table->string('supervisornumber');
$table->string('issuedate');
$table->string('expiredate');
$table->string('serialnumber')->default('000000');
// $table->boolean('checkout')->default(0);
$table->softDeletes();
$table->timestamps();
});
}

我的 Controller 代码是:

 public function store(Request $request)
{
$this->validate($request,[
'BadgeCode'=>'required|string|BadgeCode|unique:employees',
'BadgeType'=>'required',
'company_id'=>'required',
'nationality_id'=>'required',
'lastname'=>'required',
'firstname'=>'required',
'tazker'=>'required|string|tazker|unique:employees',
'telphonenumber'=>'required',
'position'=>'required',
'supervisorname'=>'required',
'supervisornumber'=>'required',
'issuedate'=>'required',
'expiredate'=>'required',
'serialnumber'=>'required'

]);
return Employee::create([
'BadgeCode'=>$request['BadgeCode'],
'BadgeType'=>$request['BadgeType'],
'company_id'=>$request['company_id'],
'nationality_id'=>$request['nationality_id'],
'lastname'=>$request['lastname'],
'firstname'=>$request['firstname'],
'telphonenumber'=>$request['telphonenumber'],
'position'=>$request['position'],
'supervisorname'=>$request['supervisorname'],
'supervisornumber'=>$request['supervisornumber'],
'issuedate'=>$request['issuedate'],
'tazker'=>$request['tazker'],
'expiredate'=>$request['expiredate'],
'serialnumber'=>$request['serialnumber'],
]);
}

Employees.vue 中的 HTML 代码是

<div class="form-group">
<input v-model="form.BadgeCode" placeholder="Enter BadgeCode" type="text" name="BadgeCode" class="form-control" :class="{ 'is-invalid': form.errors.has('BadgeCode') }" />
<has-error :form="form" field="BadgeCode"></has-error>
</div>
<div class="form-group">
<input v-model="form.tazker" placeholder="Enter tazker" type="text" name="tazker" class="form-control" :class="{ 'is-invalid': form.errors.has('tazker') }" />
<has-error :form="form" field="tazker"></has-error>
</div>

最佳答案

删除 BadgeCode 验证属性

         $this->validate($request,[           
'BadgeCode'=>'required|string|unique:employees',
'BadgeType'=>'required',
'company_id'=>'required',
'nationality_id'=>'required',
'lastname'=>'required',
'firstname'=>'required',
'tazker'=>'required|string|tazker|unique:employees',
'telphonenumber'=>'required',
'position'=>'required',
'supervisorname'=>'required',
'supervisornumber'=>'required',
'issuedate'=>'required',
'expiredate'=>'required',
'serialnumber'=>'required'


]);

关于mysql - 消息: "Method Illuminate\Validation\Validator::validateTazker does not exist.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58334887/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com