Moloquent ia a MongoDB based Eloquent model and Query builder for Laravel
Questions tagged [moloquent]
23 questions
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…

Luigi De Francisci
- 189
- 2
- 6
3
votes
0 answers
Unit tests with Laravel Moloquent CRUD operations failing on time stamp and dates
I'm trying to test my CRUD methods, but it failing because laravel TestCase Method assertDatabaseHas() cant compare the fields that uses timestamp o Date as type because it is converted to MongoDB\BSON\UTCDateTime, is there any work arround, coz now…

Ivan Vilanculo
- 648
- 1
- 11
- 25
2
votes
3 answers
Error while 'composer require jenssegers/mongodb' adding MongoDB to new Laravel 7 Project
After fresh installation of laravel 7 project,
C:\xampp\htdocs\blog>composer require jenssegers/mongodb --ignore-platform-reqs
But this is giving an error.
Your requirements could not be resolved to an installable set of packages.
Problem 1
…

RoshJ
- 461
- 1
- 6
- 24
1
vote
1 answer
How to use groupBy Month and Sum in laravel MongoDB
Query to get monthly orders (total orders per month(count) or total sales per month(sum)):
Tried this query, but it is not working. Also tried with other results from StackOverflow, but I didn't understand how it is done with MongoDB query. This is…

RoshJ
- 461
- 1
- 6
- 24
1
vote
0 answers
Laravel Select Raw into Moloquent Query
Previously, Im using Mysql for database. Once data keep growing, i'm tried to migrate to MongoDB. Im using jenssegers/laravel-mongodb just for analytics part. I found that it is difficult to fetch the data if i want to groupby per month, day, year…

ZeroOne
- 8,996
- 4
- 27
- 45
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
2 answers
How to use telescope with moloquent / mongodb?
Showing Error
{message: "Call to a member function prepare() on null",…} exception:
"Symfony\Component\Debug\Exception\FatalThrowableError" file:
"/var/www/html/broc/vendor/laravel/framework/src/Illuminate/Database/Connection.php"
line: 326…

Yuvraj Singh Shekhawat
- 313
- 2
- 15
1
vote
1 answer
Laravel - Mongodb Create new error
I'm using the laravel-mongodb library ( https://github.com/jenssegers/laravel-mongodb )
When I want to create a new record, i get this error:
strlen() expects parameter 1 to be string, array given
in…

Willl2
- 13
- 2
0
votes
0 answers
Make query on array of objects in laravel mongo
Laravel Version: 9
PHP Version: 8.1
jenssegers/mongodbn: 3.9
At my model there's a field that represents an array of object, actually are instoke of my record, for example:
{ "item": "journal", "instock": [ { "warehouse": "A", "qty": 5 }, {…

ali amini
- 11
- 1
0
votes
0 answers
Moloquent laravel hasOne & hasMany not working with foreignKey in ObjectId
I'm Using jenssegers/laravel-mongodb library in my Laravel MongoDB application. However, the hasOne relationship is only working if foreignKey in a string. if it saves as a ObjectId type, the relationship gives an empty result.
MongoDB document…

Miuranga
- 2,463
- 10
- 51
- 81
0
votes
1 answer
Retrieve subDocument on Moloquent
I have this document
{
_id: ObjectId('5f8970f19e6afb628a2edd07'),
name: 'pack 1',
price: 100,
min_price: 100,
updated_at: ISODate('2020-10-16T10:07:45.570Z'),
created_at: ISODate('2020-10-16T10:07:45.530Z'),
…

Luigi De Francisci
- 189
- 2
- 6
0
votes
1 answer
Laravel mongodb where array field contains value
I use mongodb and mysql together with Laravel.
Fields table in mysql database can have more options in mysql database.
fields table in mysql: id, name
options table in mysql: id, field_id, name
so in mongodb database I have adverts table and this…

Ozal Zarbaliyev
- 566
- 6
- 22
0
votes
0 answers
Getting a hasMany relationship inside a document with MongoDB and Laravel
Just trying to do some relationship on Laravel with MongoDB, but I'm getting a null on my requests.
I have a "passengers" collection with a trip_id. Something like this:
{
"id":"5d680fd36882d19e782d67bd",
…

Louis B
- 306
- 5
- 18
0
votes
1 answer
How to make moloquent's embedsOne relations work?
I tried the example from the documentation. I got two classes:
namespace App;
use Moloquent\Eloquent\Model as Eloquent;
class Author extends Eloquent
{
protected $fillable = [ 'name' ];
}
class Book extends Eloquent
{
public function…

Bernhard
- 1
0
votes
1 answer
How to use "Jenssegers\Mongodb" in User model - Laravel 5.5
I want to use "Jenssegers\Mongodb" package in a Laravel 5.5 app.
The package documentation tells to use:
use Jenssegers\Mongodb\Eloquent\Model;
class User extends Model {}
instead of:
use Illuminate\Database\Eloquent\Model;
class User extends Model…

Rowayda Khayri
- 489
- 1
- 9
- 21