Can we use join or aggregrate in laravel with model? #2509
Unanswered
himanshuthakurmagictym
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Can we use join or aggregrate in laravel with model?
i have try to do it but I am getting error:
{ "message": "call_user_func_array(): Argument #1 ($callback) must be a valid callback, class MongoDB\\Collection does not have a method \"aggregrate\"", "exception": "TypeError", "file": "/var/www/html/CW_V2/html/vendor/jenssegers/mongodb/src/Collection.php", "line": 42, "trace": [ { "file": "/var/www/html/CW_V2/html/vendor/jenssegers/mongodb/src/Collection.php", "line": 42, "function": "call_user_func_array" }, ...............................................
My model:
`<?php
namespace Modules\Report\Entities;
use Jenssegers\Mongodb\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Modules\Websites\Entities\Websites;
class ReportOutput extends Model
{
use HasFactory;
}
`
my controller function :
` return ReportOutput::raw(function($collection){
return $collection->aggregrate([['$match' => ['site_id' => 'site_id']]],
Beta Was this translation helpful? Give feedback.
All reactions