I've used Backpack for Laravel to generate a super-simple admin dashboard on my local app dev computer. Now I'm using Git to push it to a remote "hub" server (my own, not GitHub) and then pulling it into a remote "beta" server for testing.
Everything seems fine ... I can navigate among the several CRUDs I've generated, the data appears OK, etc.
BUT when I click an Edit link or click the + Add <entity>
button I get
ERROR
500
It's not you, it's me.
Please pass setValidation() nothing, a rules array or a FormRequest class.
The App Dev and the Beta codebase should be identical, thanks to Git. But obviously some difference has crept in somewhere. Does that error message suggest to anyone where the difference might be?
Details:
PHP 7.4.33 on Beta, 7.4.19 on App Dev
LARAVEL v8.83.27 on both
backpack/crud: 5.5.1 on both
backpack/generators: 3.3.16 on both
Thanks!
It seems one of your CrudController
is trying to send an invalid argument to CRUD::setValidation(...)
method.
As the error states, setValidation
allows "a rules array or a FormRequest class".
Usually, I opt for the FormRequest class, and it goes like CRUD::setValidation(EntityRequest::class)
. Also note that you're probably using this method twice in your controllers, in setupCreateOperation
and setupUpdateOperation
.
public function setupCreateOperation()
{
CRUD::setValidation(EntityRequest::class);
}
public function setupUpdateOperation()
{
CRUD::setValidation(EntityRequest::class);
}
You may also send a rules array, as the docs point out;
CRUD::setValidation([
'name' => 'required|min:2',
// ...
]);
Please check wherever you're using setValidation
because at least one of it is wrong.
Side note, if you are starting a new project, I highly recommend you to use the latest PHP (8.2, or at least 8.1) and latest Laravel (10). Backpack supports both.