Questions tagged [jenssegers-mongodb]

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

An Eloquent model and Query builder with support for MongoDB, using the original Laravel API. This library extends the original Laravel classes, so it uses exactly the same methods.

GitHub Link

192 questions
1
vote
0 answers

How to add laravel-medialibrary into Laravel/mongodb app?

I need to add spatie/laravel-medialibrary 10 into Laravel 9 app with jenssegers/mongodb:^3.9 I modified model app/Models/CMSItem.php decalaration :
mstdmstd
  • 2,195
  • 17
  • 63
  • 140
1
vote
1 answer

Why I got duplicate key error collection: sessions index error with jenssegers/mongodb?

I started new laravel 9 (with jet and inertia, without team) app with "jenssegers/mongodb": "^3.9" installed. I changed connection to mongo MngProducts database and run migrations. But running homepage with controller defined I got error on second…
mstdmstd
  • 2,195
  • 17
  • 63
  • 140
1
vote
0 answers

How to execute raw query in jenssegers/laravel-mongodb

I'm looking to make a query that gets all the existing indexes of a collection. I have tried the following code: DB::connection('mongodb')->getMongoDB()->execute("db.registrations.getIndexes()") But getting error Call to undefined method…
1
vote
0 answers

Jenssegers/laravel-mongodb transactions doesn't rollback

I need to use transactions in laravel 8 and I'm using the Jenssegers-laravel-mongodb package. The beginTransaction method on the DB facade doesn't work for mongoDB, so I tried the following method: $session =…
1
vote
1 answer

Authentication failed in laravel test

I'm trying to write a test but I can't authenticate with a fake test user, I'm using mongodb, jenssegers/laravel-mongodb and jwt-auth this is the factory I've created
af_159623
  • 197
  • 10
1
vote
1 answer

Laravel MongoDB cannot get belongsTo relationship properly value

When using jenssegers/laravel-mongodb, the belongsTo relationship properly always returns null, despite, when dumping, the value appearing. How can I get the belongsTo relationship? I have two models, a post and a user. Where the post has a belongs…
NeedHelp101
  • 599
  • 1
  • 9
  • 25
1
vote
1 answer

Using Jenssegers MongoDB with Slim and Capsule

I am using the Slim 4 framework along with Jenssegers MongoDB library and Capsule (Illuminate\Database from Laravel). I have got the MongoDB extension installed on my Linux server and everything seems ok connection wise, but I cannot seem to insert…
jelly5798
  • 349
  • 2
  • 9
1
vote
0 answers

Pagination takes too long to load using nested attribute

I encountered a problem when trying to paginate data that's coming from mongodb. Here's the code: $projection = [_id, addresses]; $connection = \DB::connection('mongodb'); $data = $connection->collection('my_collection') …
Sargis
  • 168
  • 4
  • 12
1
vote
0 answers

Laravel + Mongo DB latest unique entries from database

I'm working on a Laravel + Mongo DB project where we store data like this: _id | machinename | SoftwareKey | created_at ----------------------------------------- 5cf6c4a7fdce2778e833dd88 | VM007 | TestSoftware |…
NicuVlad
  • 2,491
  • 3
  • 28
  • 47
1
vote
1 answer

How do i find collection through a record related to the first collection

I need to find a group of collection WHERE the search is based on a record on a related model. To let you understand I need to get users with the company name that is LIKE my search input. Here's what i've tried: $users = App\User::with(['company'…
McMazalf
  • 59
  • 1
  • 9
1
vote
1 answer

use auto increment id with jenssegers mongodb laravel

I need auto generate id sequence. I am using jenssegers. I have a UseAutoIncrementID trait from here. And using it as: use App\Traits\UseAutoIncrementID; .... .... $data['_id'] = $this->getID('request_feeds'); // request_feeds is collection name. I…
Azima
  • 3,835
  • 15
  • 49
  • 95
1
vote
2 answers

Laravel Moloquent. Add projection to related model

I have a query with relation. $dbQuery = $this->someModel ->where('user_id', '<>', Auth::id()) ->with(['questions']) ->get(['title', 'status', 'expired_at']); The list of fields in get() method define the list of selected fields for the…
Denys Siebov
  • 198
  • 4
  • 16
1
vote
0 answers

belongsToMany, hybrid relation

I have 2 simple models. First, one is called Builds (mysql) and the second one is called SlotOptions (mongodb). Each build can have 5 assigned slots. Based on https://stackoverflow.com/a/55132863/2513428 select * from `builds` where `builds`.`id` =…
Kavvson Empcraft
  • 445
  • 7
  • 32
1
vote
1 answer

How do I extract subdocument in laravel mongodb

Hello Good Developers, I am using jenssegers/laravel-mongodb package to query my MongoDB from Laravel. Here's Fiddle for my query: https://mongoplayground.net/p/qzbNN8Siy-3 I have following JSON [{ "id": "GLOBAL_EDUCATION", "general_name":…
Pankaj Jha
  • 886
  • 15
  • 37
1
vote
2 answers

Get latest row of each group by with Laravel MongoDB

I have a table called gps in a MongoDB that looks like this: | id | asset_id | coordinates | created_at | -------------------------------------------- | 1 | 11 | 23,-26 | 2018-11-05 | | 2 | 22 | 33,-36 | 2018-10-04 | | 3 |…