Wildcard-like syntax in an eloquent Where clause to search between two strings

I saw the answer provided in this question Wildcard-like syntax in an eloquent Where clause? now I want to know if is there a way to search between two strings?.

basicasicaly in my code I want to show requests that have a status of new or scheduled.

$requests = DB::table('requests')
        ->select('requestDate','requestTime','status','requestID')
        ->where('requestorID', '=',$userID)
        ->where('status', 'LIKE','%New%')
        ->get();

>Solution :

you can use whereIn ,The whereIn method verifies that a given column’s value is contained within the given array:

$requests = DB::table('requests')
        ->select('requestDate','requestTime','status','requestID')
        ->where('requestorID', '=',$userID)
        ->whereIn('status', ['new','scheduled'])
        ->get();

Leave a Reply