Support the ongoing development of Laravel.io →
Eloquent Database
Last updated 2 years ago.
0

try to use carbon for this

0
use Carbon/Carbon;
use {model_namespace}/Banner;
$banner = Banner::where('valid_from', '<=', Carbon::createFromFormat('Y-m-d H:i:s', '2018-10-03 13:20:52')->toDateTimeString())
->orWhere('valid_to', '>=', Carbon::createFromFormat('Y-m-d H:i:s', '2018-10-03 13:20:52')->toDateTimeString())
->orWhere('channel', 'en-us')
->orWhere('language', 'en')
->orWhere('valid_to', null)
->orWhere('channel', null)
->orWhere('language', null)
->get();

The above script will give you the same data as you want.

Last updated 5 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Balan Dur balandur Joined 3 Oct 2018

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.