Ansel

165 经验值

Jelly解决了,我的一个朋友给我发了他的validation,覆盖了就好了,我也不知道是什么暗黑原理,这么晚了,真心感激你,少熬夜,注意身体啊

这个我也忘了改回来。。。就算是required也是一样。。。

没有那个逗号的话也是一样的,我调试的时候忘了改回来了

public function useDemo(Requests\ValidateDemoRequest $request )
    {

        Tour::create($request->all());
        return redirect('/tour_index');
    }
    {

        Tour::create($request->all());
        return redirect('/tour_index');
    }
<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class ValidateDemoRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'id'       => 'require',
        ];
    }
}

  }

似乎我的validator就是少一个方法呢。Jelly,如果你还没有休息的话,介不介意帮我看一看你的Illuminate\Validation\Validator .php 中有没有报错的这个方法呢 @JellyBool

我有将rules的规则注释掉,然而还是不行,改成用validate验证,报相同的错误,我use的文件应该都没有错的,提示有个方法找不到,我去找个那个方法,也确实没找到

我使用命令行工具新建了一个Request,并写入规则,传入控制器的方法,可是验证时出现了错误

BadMethodCallException in Validator.php line 2615:

Method [validateRequire] does not exist.

1. in Validator.php line 2615
2.at Validator->__call('validateRequire', array('published_at', '2015-10-24', array(), object(Validator))) in Validator.php line 362
3.at Validator->validateRequire('published_at', '2015-10-24', array(), object(Validator)) in Validator.php line 362
4.at Validator->validate('published_at', 'require') in Validator.php line 314
5.at Validator->passes() in ValidatesWhenResolvedTrait.php line 24
6.at FormRequest->validate() in ValidationServiceProvider.php line 32
7.at ValidationServiceProvider->Illuminate\Validation\{closure}(object(CreateArticleRequest), object(Application)) in Container.php line 1018
8.at Container->fireCallbackArray(object(CreateArticleRequest), array(object(Closure))) in Container.php line 984
9.at Container->fireResolvingCallbacks('App\Http\Requests\CreateArticleRequest', object(CreateArticleRequest)) in Container.php line 645
10.at Container->make('App\Http\Requests\CreateArticleRequest', array()) in Application.php line 674
11.at Application->make('App\Http\Requests\CreateArticleRequest') in RouteDependencyResolverTrait.php line 61
12.at ControllerDispatcher->resolveMethodDependencies(array(), object(ReflectionMethod)) in RouteDependencyResolverTrait.php line 41
13.at ControllerDispatcher->resolveClassMethodDependencies(array(), object(ArticlesController), 'store') in ControllerDispatcher.php line 162
14.at ControllerDispatcher->call(object(ArticlesController), object(Route), 'store') in ControllerDispatcher.php line 112
15.at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
16.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
17.at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
18.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
19.at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114
20.at ControllerDispatcher->callWithinStack(object(ArticlesController), object(Route), object(Request), 'store') in ControllerDispatcher.php line 69
21.at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\ArticlesController', 'store') in Route.php line 201
22.at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
23.at Route->run(object(Request)) in Router.php line 704
24.at Router->Illuminate\Routing\{closure}(object(Request))
25.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
26.at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
27.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
28.at Pipeline->then(object(Closure)) in Router.php line 706
29.at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 671
30.at Router->dispatchToRoute(object(Request)) in Router.php line 631
31.at Router->dispatch(object(Request)) in Kernel.php line 236
32.at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
33.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
34.at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
35.at VerifyCsrfToken->handle(object(Request), object(Closure))
36.at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
37.at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
38.at ShareErrorsFromSession->handle(object(Request), object(Closure))
39.at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
40.at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
41.at StartSession->handle(object(Request), object(Closure))
42.at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
43.at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
44.at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
45.at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
46.at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
47.at EncryptCookies->handle(object(Request), object(Closure))
48.at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
49.at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
50.at CheckForMaintenanceMode->handle(object(Request), object(Closure))
51.at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
52.at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
53.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
54.at Pipeline->then(object(Closure)) in Kernel.php line 122
55.at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
56.at Kernel->handle(object(Request)) in index.php line 54

求帮忙看看是怎么回事