laravel-doctrine / orm

A drop-in Doctrine ORM 2 implementation for Laravel 5+ and Lumen
http://laraveldoctrine.org
MIT License
823 stars 180 forks source link

[BUG] Laravel 11 "validation.presence" not overriden #576

Open xaben opened 2 weeks ago

xaben commented 2 weeks ago

Laravel 11 upgrade not possible due to all the validations failing as service is not being overridden.

Package version, Laravel version

laravel-doctrine/orm 2.1.0 laravel/framework v11.10.0

Expected behaviour

LaravelDoctrine\ORM\Validation\DoctrinePresenceVerifier is returned when trying to fetch "validation.presence" service

Actual behaviour

Illuminate\Validation\DatabasePresenceVerifier is returned instead

Steps to reproduce the behaviour

Add an Exists validation as described in https://laraveldoctrine.org/docs/1.8/orm/validation

colorninja commented 6 days ago

I manager to solve this by adding the following to my AppServiceProvider:

$this->app->singleton(DoctrinePresenceVerifier::class);
$this->app->extend('validation.presence', fn () => app()->get(DoctrinePresenceVerifier::class));

A bit hacky but a step in the right direction. I can look into submitting a PR this weekend.