$transactionType = ['request','transfer'];
$transactions = Transaction::where(function ($query) use
($request) {
if (in_array("request", $transactionType))) {
return $query->where('transactionType', 'request');
}
if (in_array("transfer", $transactionType)) {
return $query->where('transactionType', 'transfer');
}
})->get();
I want it to return both returns as $transaction
contain both element 'transfer' and 'request' but it is returning only $query->where('transactionType', 'request');
CodePudding user response:
Maybe this is what you're looking for,
$transactionType = ['request','transfer'];
$transactions = Transaction::whereIn('transactionType', $transactionType)->get();