Sep 4, 2022
0
Level 1
How to insert parameters into a MongoDB eloquent aggregation function?
I have the following code in my controller.
public function show(Request $request) {
$data = Book::raw(function ($collection, Request $request) {
return $collection->aggregate([
[
'$match' => [
'T.HD.HD02' => ['$eq' => $request->date]
],
],
]);
});
}
I am receiving parameters from my Blade file and I want to insert them into this function. The name T.HD.HD02 refers to a date entered by the user.
The variable Request $request doesn't even work inside the function.
How can I make it recognize the Request parameters?
Please or to participate in this conversation.