Replies: 1 comment
|
The preset is flagging an HTTP-layer dependency, not saying that Livewire cannot validate the same data. In the current Laravel preset, the relevant rule is: expect('App\Http')
->toOnlyBeUsedIn(['App\Http', 'App\Providers']);See Laravel.php. Because Keep the preset and extract only the reusable definition: final class CpdRules
{
public static function rules(): array
{
return [
// shared rules...
];
}
}
final class CpdRequest extends FormRequest
{
public function rules(): array
{
return CpdRules::rules();
}
}
final class CpdSave extends Component
{
protected function rules(): array
{
return CpdRules::rules();
}
}Put Your If this resolves the architecture question, please mark it as the answer so the reason for the preset failure is easy to find. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
The Pest architecture test (arch()->preset()->laravel()) enforces that Form Request classes should only be used in Controllers. However, CpdSave.php is importing CpdRequest to reuse its validation rules:CpdSave.phpis a livewire full page controller, am I doing something bad/wrong here? Or should Pest architecture test be adjusted to allow Form Requests to be used in Livewire?I was able to resolve it by setting
arch()->preset()->laravel()->ignoring('App\Livewire');as a workarround.All reactions