È possibile utilizzare whereRaw()
per aggiungere un grezzo in cui la clausola alla query, ad esempio:
$results = SpPrice::whereRaw("('2014-08-15' between `from_date` and `to_date`) || ('2014-09-18' between `from_date` and `to_date`)")->get();
O forse è possibile utilizzare DB::raw()
come primo argomento di whereBetween()
, ma non sono sicuro se è possibile, in questo caso è possibile utilizzare orWhere()
con una chiusura a dare una codice più leggibile, ad esempio:
SpPrice::whereBetween(DB::raw('"2014-08-15"'), ['from-date', 'to_date'])->orWhere(function($q)
{
$q->whereBetween(DB::raw('"2014-09-18"'), ['from-date', 'to_date']);
});
Ma Non sono abbastanza sicuro che se funziona, provalo.
fonte
2014-09-28 06:59:20
Cosa hai provato che non ha funzionato? – mbouzahir
@mbouzahir Aggiorna la mia domanda. Vedere la domanda di aggiornamento –