Я добавил proengsoft / laravel -jsvalidation в мое приложение laravel 6, которое нормально работает на моем Ubuntu 18 с PHP 7.2.24 Но Мой клиент, извлекающий версию, получил ошибку на своем Windows / php 7.4.2 as:
#57 C:\\xampp\\htdocs\\primewatch\\public\\index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#58 {main}
[previous exception] [object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Argument 2 passed to Proengsoft\\JsValidation\\JsValidatorFactory::__construct() must be of the type array, null given, called in C:\\xampp\\htdocs\\primewatch\\vendor\\proengsoft\\laravel-jsvalidation\\src\\JsValidationServiceProvider.php on line 38 at C:\\xampp\\htdocs\\primewatch\\vendor\\proengsoft\\laravel-jsvalidation\\src\\JsValidatorFactory.php:37)
[stacktrace]
#0 C:\\xampp\\htdocs\\primewatch\\vendor\\proengsoft\\laravel-jsvalidation\\src\\JsValidationServiceProvider.php(38): Proengsoft\\JsValidation\\JsValidatorFactory->__construct(Object(Illuminate\\Foundation\\Application), NULL)
#1 C:\\xampp\\htdocs\\primewatch\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(799): Proengsoft\\JsValidation\\JsValidationServiceProvider->Proengsoft\\JsValidation\\{closure}(Object(Illuminate\\Foundation\\Application), Array)
#2 C:\\xampp\\htdocs\\primewatch\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(681): Illuminate\\Container\\Container->build(Object(Closure))
#3 C:\\xampp\\htdocs\\primewatch\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(785): Illuminate\\Container\\Container->resolve('jsvalidator', Array, true)
#4 C:\\xampp\\htdocs\\primewatch\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(629): Illuminate\\Foundation\\Application->resolve('jsvalidator', Array)
#5 C:\\xampp\\htdocs\\primewatch\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(770): Illuminate\\Container\\Container->make('jsvalidator', Array)
#6 C:\\xampp\\htdocs\\primewatch\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(1245): Illuminate\\Foundation\\Application->make('jsvalidator')
#7 C:\\xampp\\htdocs\\primewatch\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Facades\\Facade.php(198): Illuminate\\Container\\Container->offsetGet('jsvalidator')
#8 C:\\xampp\\htdocs\\primewatch\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Facades\\Facade.php(166): Illuminate\\Support\\Facades\\Facade::resolveFacadeInstance('jsvalidator')
#9 C:\\xampp\\htdocs\\primewatch\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Facades\\Facade.php(255): Illuminate\\Support\\Facades\\Facade::getFacadeRoot()
#10 C:\\xampp\\htdocs\\primewatch\\storage\\framework\\views\\68757a9c9b2f658eb9358cc98549740ca7f9e23d.php(34): Illuminate\\Support\\Facades\\Facade::__callStatic('formRequest', Array)
#11 C:\\xampp\\htdocs\\primewatch\\vendor\\laravel\\framework\\src\\Illuminate\\View\\Engines\\PhpEngine.php(43): include('C:\\\\xampp\\\\htdocs...')
#12 C:\\xampp\\htdocs\\primewatch\\vendor\\laravel\\framework\\src\\Illuminate\\View\\Engines\\CompilerEngine.php(59): Illuminate\\View\\Engines\\PhpEngine->evaluatePath('C:\\\\xampp\\\\htdocs...', Array)
#13 C:\\xampp\\htdocs\\primewatch\\vendor\\facade\\ignition\\src\\Views\\Engines\\CompilerEngine.php(36): Illuminate\\View\\Engines\\CompilerEngine->get('C:\\\\xampp\\\\htdocs...', Array)
#14 C:\\xampp\\htdocs\\primewatch\\vendor\\laravel\\framework\\src\\Illuminate\\View\\View.php(143): Facade\\Ignition\\Views\\Engines\\CompilerEngine->get('C:\\\\xampp\\\\htdocs...', Array)
У меня есть приложение / Http / Requests / ShipRequest. php с:
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Request;
use App\Http\Traits\funcsTrait;
use App\Ship;
class ShipRequest extends FormRequest
{
use funcsTrait;
/**
* 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()
{
$request= Request();
return Ship::getValidationRulesArray( $request->get('id') );
}
}
А в методе модели корабля getValidationRulesArray определяется как:
public static function getValidationRulesArray($ship_id= null) : array
{
$validationRulesArray = [
'title' => [
'required',
'string',
'max:255',
Rule::unique(with(new Ship)->getTable())->ignore($ship_id),
],
'company_id' => 'required|exists:' . ( with(new Company)->getTable() ).',id',
];
return $validationRulesArray;
}
Интересно, почему такая ошибка на Windows / php 7.4. Это может быть php другой вопрос или что?
"laravel/framework": "^6.2",
"proengsoft/laravel-jsvalidation": "^2.5",
Спасибо!