andyandy
1 month ago

Eloquent modify DB data before comparing them with where()

Posted 1 month ago by andyandy

I want to make sure that text is not duplicate. Something like:

$record = Record::where('text', request('text'))->

But I want to strtolower and preg_replace before comparing them. Easy to do on request('text') side:

$record = Record::where('text', preg_replace('/[^a-z0-9]+/u', '', strtolower(request('text'))))->

But ho do I also modify DB data in text column (strtolower + preg_replace) before comparing them? Is that possible?

Please sign in or create an account to participate in this conversation.