mitchellvanw / laravel-doctrine

NO LONGER MAINTAINED! A Doctrine 2 implementation that melts with Laravel
MIT License
187 stars 74 forks source link

Validation - uniqueness #38

Closed kirkbushell closed 9 years ago

kirkbushell commented 10 years ago

Currently if you try and run the uniqueness validation that L4 provides, it will go via Eloquent, setting up a new database connection and do all that double-edged lovely goodness. The problem is, that's not what we want - we need to setup a new DatabasePresenceVerifier that can handle this for us.

This isn't as straight-forward as we'd like. Any ideas as to how this could be handled nicely? Open question/brainstorm session to see what we can come up with.

mitchellvanw commented 10 years ago

Creating an implementation should be simple enough. It'll have to implement the PresenceVerifierInterface. Then override the validation.presence binding in the Container and it should be fine. You can find the binding here, but I do believe there should be a better way to interchange a presence verifier in Laravel.

kirkbushell commented 10 years ago

Yeah I've got it done. Got PR esoteric once my other stuff is in. On 21 Sep 2014 15:47, "Mitchell van Wijngaarden" notifications@github.com wrote:

Creating an implementation should be simple enough. It'll have to implement the PresenceVerifierInterface https://github.com/illuminate/validation/blob/master/PresenceVerifierInterface.php. Then override the validation.presence binding in the Container and it should be fine. You can find the binding here https://github.com/illuminate/validation/blob/master/ValidationServiceProvider.php#L68

— Reply to this email directly or view it on GitHub https://github.com/mitchellvanw/laravel-doctrine/issues/38#issuecomment-56300884 .

jonesio commented 10 years ago

:+1:

philipbrown commented 9 years ago

Hey @kirkbushell ,

Hopefully this is just me being dumb, but I can't get the validation uniqueness to work :sweat:

Whenever I set up a test with an existing user, and then run the validation check, no results are ever returned.

It seems to me that the native query builder won't work in this situation because you need to set the result mapping, e.g http://doctrine-orm.readthedocs.org/en/latest/reference/native-sql.html#examples

Which wouldn't work because you would have no idea what to map at runtime.

Am I missing something really obvious? :flushed:

mrsimonbennett commented 9 years ago

+1 to this