In my Laravel project I use some MySQL based SQL functions in my queries, like this:
Post::whereRaw('publish_at < NOW()');
SELECT * FROM posts WHERE publish_at < NOW();
Or this:
Post::whereRaw('TIMESTAMP(publish_date, publish_time) < NOW()');
SELECT * FROM posts WHERE TIMESTAMP(publish_date, publish_time) < NOW();
These queries works fine with MySQL db, but if I try to test them on SQLite in-memory database, they fail because of:
no such function: NOW (SQL: ...)
I want to keep the benefits of MySQL functions, but I don't want to drop these tests, nor create a different functions to use it in tests.
Maybe is there any less known Eloquent functions to solve these issues?
Any idea how can I make it work on both databases?