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
10
votes
1 answer

Laravel Jenssegers MongoDb Relationships not working?

I'm trying to setup some simple favoriting for my app using Laravel/Jenssegers MongoDB I have two models: class Item { public function favorites() { return $this->hasMany('App\Models\User', 'favorites'); } } class User { …
Rob
  • 10,851
  • 21
  • 69
  • 109
8
votes
1 answer

Can't install jenssegers/mongodb in Laravel 10

I am new to Laravel. I want to connect to MongoDB using Laravel 10 which require jenssegers/mongodb to be installed. When I run command composer require jenssegers/mongodb 3.8.0 --ignore-platform-reqs in the terminal, I got error like this: PHP…
Atapol
  • 85
  • 1
  • 5
8
votes
3 answers

Installing Jenssegers/MongoDB in a Laravel Sail 8.0 environment

So I've managed to do a clean install of Laravel in Windows using WSL2. One of the requirements of my project is to have two databases running at the same time mysql and mongodb. I added an image of MongoDB in my docker-compose.yml as the dock-hub…
Helena
  • 121
  • 1
  • 3
7
votes
4 answers

Connect laravel jenssegers to mongodb atlas cluster

I'am starting with Mongodb atlas and i trying to connect my laravel/jenssegers project to the cluster i config my conf/database 'mongodb' => [ 'driver' => 'mongodb', 'host' => env('DB_HOST'), 'port' => env('DB_PORT', '27017'), …
6
votes
4 answers

laravel get error of Call to a member function prepare() on null

In Laravel I have got this error, while inserting a record in my MongoDB database. Call to a member function prepare() on null namespace App\Http\Controllers; use App\Employee; use Illuminate\Http\Request; class EmployeeController extends…
John_rees
  • 93
  • 1
  • 3
  • 12
6
votes
1 answer

How to convert MongoDB aggregation query to Laravel MongoDB by jenssegers

I have MongoDB collection called changes which contains following data { "date" : ISODate("2014-06-09T00:00:00.000Z"), "field" : "ip", "from" : "157.11.209.123", "to" : "107.21.109.254" } { "date" :…
5
votes
0 answers

Laravel Jensseger Mongodb belongsToMany additional fields

the documentation says "The belongsToMany relation will not use a pivot "table", but will push id's to a related_ids attribute instead. This makes the second parameter for the belongsToMany method useless. If you want to define custom keys for your…
5
votes
2 answers

Laravel Eloquent: How to pass connection name to relationship model

I have two models, one mongo model extending Jenssegers\Model and other sql model extending Illuminate\Model. This sql model doesn't have connection name defined as we're having multiple database connectivity have same table in each database. Mongo…
Haridarshan
  • 1,898
  • 1
  • 23
  • 38
5
votes
0 answers

Laravel + Jenssegers\Mongodb: 'WhereHas' and 'Has' returns empty collection

I'm mainly working on two models right now, Form and Notification, and a many-to-many relationship is set up and working for most Eloquent commands, except for whereHas and has. Both just return an empty array, []. It seems like the developer has…
Hollings
  • 534
  • 5
  • 14
5
votes
0 answers

How to make read from slave and write at master in mongodb with replicaset using laravel

I am working with laravel 5.1 with mongodb. For mongodb I am using jenssegers mongo configuration. Now I have to make mongodb replica set and I want to make read operation only from slave & write operation at master. In laravel's documentation I…
5
votes
3 answers

Laravel Mongodb Raw mongo query with date

I am working on laravel 5.1 and using jessenger mongodb package. I am using raw query to fetch data but i am confused how to use date with that as currently it is returning null result. $resultSet =…
Sameer Sheikh
  • 499
  • 1
  • 6
  • 16
5
votes
1 answer

jenssegers/laravel-mongodb regex in where not working

I'm working on a Laravel API with a MongoDB database using jenssegers/laravel-mongodb. I'm trying to make a filter to get some particular data using a regex. In the tutorial for this plugin I found this: User::where('name', 'regex', new…
gidomanders
  • 465
  • 5
  • 16
4
votes
1 answer

How to apply regex properly in Jenssegers raw() function

I tried to implement a diacritic insensitive full word search in one of my application. I wrote this query and is working fine in the MongoDB terminal (I used Robo3T). [ Here I passed the Unicode conversion of the word 'Irène'…
Anoop Sankar
  • 619
  • 5
  • 16
4
votes
1 answer

How do I get all matching sub array Objects in mongoDB

I have following JSON [ { "_id": "5c87e621257db42508007f3b", "uuid": "8b03dba7-db96-40d0-8dd9-6a65efd6719a", "user_answers": [ { "profile_section_code": "MY_PROFILE", "profile_question_code":…
4
votes
0 answers

Query with date range works when executed directly on Mongo but fails when used from Laravel

I have two collections called promotions and coupons Coupons has promotion._id as reference to promotion collection. I want to fetch the promotions within a date range. For this, I have two fields valid_from and apply_till. "valid_from" :…
San
  • 666
  • 7
  • 27
1
2 3
12 13