Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel:如果请求规则不正确,请登录数据库_Laravel_Request_Rules - Fatal编程技术网

Laravel:如果请求规则不正确,请登录数据库

Laravel:如果请求规则不正确,请登录数据库,laravel,request,rules,Laravel,Request,Rules,如果请求规则不正确,我想登录数据库 \Validator::extend( 'my_validator', function ( $attribute, $value, $parameters ) { $result = \DB::table( 'table' )->where( 'field1', $value )->where( 'field2', 'Y' )->exists(); if ( !$result ) { // Log in database the v

如果请求规则不正确,我想登录数据库

\Validator::extend( 'my_validator', function ( $attribute, $value, $parameters ) {
$result = \DB::table( 'table' )->where( 'field1', $value )->where( 'field2', 'Y' )->exists();
if ( !$result ) {
    // Log in database the value of request->field3, request->field4, ...
    $log = new Log();
    $log->date = Carbon::now();
    $log->field3 = $request->field3;  // <<= How can I access here the input request of the fromula?
    $log->field4 = $request->field4;  // <<= How can I access here the input request of the fromula?
    // ... 
    $status = $log->save();
}
return $result;
} );

$validationRules = [
   'field' => 'my_validator'
];
\Validator::extend('my_Validator',函数($attribute,$value,$parameters){
$result=\DB::table('table')->where('field1',$value)->where('field2','Y')->exists();
如果(!$result){
//在数据库中记录request->field3,request->field4。。。
$log=新日志();
$log->date=Carbon::now();
$log->field3=$request->field3;//field4;//“我的验证程序”
];

要访问请求字段,您应该使用facade
\request
\Input
。在这种情况下,您可以使用code
\request::get('field1')轻松获取任何字段的值要访问请求字段,您应该使用facade
\request
\Input
。在这种情况下,您可以使用code
\request::get('field1');轻松获取任何字段的值。

谢谢您的帮助!是的:$this->field谢谢您的帮助!是的:$this->field