0
votes

I'm using Lumen 5.8.4, Dingo package for making api and I'm trying to use third party package pearl (https://packagist.org/packages/pearl/lumen-request-validate) for form request validation because Lumen doesn't support it.

I've set up everything and validation logic: rules and messages works fine when I define them in class(through postmen I receive "this field is required" etc ), but when everything is fine, when all fields are OK (from frontend side) I got this message

{
    "message": "Method App\\Http\\Requests\\StoreVehicleRequest::validate does not exist.",
    "status_code": 500,
    "debug": {
        "line": 102,
        "file": "E:\\Damjan\\Programiranje\\PHP\\Laravel\\Lumen\\automoto-lumen\\vendor\\illuminate\\support\\Traits\\Macroable.php",
        "class": "BadMethodCallException",
        "trace": [
            "#0 E:\\Damjan\\Programiranje\\PHP\\Laravel\\Lumen\\automoto-lumen\\vendor\\dingo\\api\\src\\Provider\\LumenServiceProvider.php(58): Illuminate\\Http\\Request->__call('validate', Array)"...

What I see here that trace leads to dingos LumenServiceProvider where i have

 $this->app->afterResolving(ValidatesWhenResolved::class, function ($resolved) {
            $resolved->validate();
        });

and I think this one should use pearls RequestServiceProvider, where I have.

 $this->app->afterResolving(RequestAbstract::class, function ($resolved) {
            $resolved->validateResolved();
        });

Or I'm missing something here. Struggling with this whole day. Any ideas?

1

1 Answers

0
votes

OK, I've figured out what is going on. RequestServiceProvider is called but after it also Dingo is running LumenServiceProvider witch has an issue with Validator what is shown here

https://github.com/dingo/api/pull/1654/files

So I'm not sure I did the right thing, but this is my solution: because there is no publishing in Lumen, and I couldn't make it to work with third party packages I've copied LumenServiceProvider in my Provider folder, make a changes, and I've registered it in bootstrap/app.php.

It works for now, hopefully won't make any other problems.