$model = $user->find(1); $model->where(‘test’,"like",’%23%’); Sourc..
Category : mongodb
i am NOT getting result thought the data is there in DB $conditions = collect($this->getColumns())->map(function ($column, $key) use ($keyword, $or_conditions) { return $or_conditions[] = [ $column => [ ‘$regex’ => "$keyword", ‘$options’ => ‘i’ ], ]; }); $final_or_condition = [ ‘$or’ => $conditions->toArray() ]; $this->collection = $this->collection->whereRaw($final_or_condition); when i search in Datatable input field on ..
In my project, I use Laravel 8 with Mongodb as my database, and jenssegers/laravel-mongodb as its driver. Let say I have a collection named products which has relationship embedsOne to vendors. when I create a new product, how can I insert existing vendor to this new product? I tried the following $vendor = Vendor::find($request->vendor); $product ..
I try to query my collection with only one query and 3 potentials search method : fulltext search, classic search and search regex. This 3 matches can be executed at the same time or just one of them. The fulltext search is the first stage pipeline as we know. Does this fulltext search can be ..
i am having collection of employee assosiated with company use IlluminateDatabaseEloquentModel; use JenssegersMongodbEloquentModel as Eloquent; class Employee extends Eloquent { protected $casts = [ ‘has_pp’ => ‘Boolean’, ‘has_eal’ => ‘Boolean’, ‘support’ => ‘String’, ‘has_cin’ => ‘Boolean’, ‘has_lac’ => ‘Boolean’ ]; protected $fillable = [ ‘first_name’, ‘last_name’, ‘has_pp’, ‘has_eal’, ‘support’, ‘has_cin’, ‘has_lac’ ]; public function company(){ ..
I was using "jenssegers/mongodb": "2.1" and switched to "jenssegers/mongodb": "3.0.x" while upgrading from Laravel5.0 to Laravel 5.1 with php 5.6.x I modified my codes for the upgraded version, but I’m no longer able to get the results count as used to before with this code: $results = DB::connection($connection) ->collection("listing") ->timeout(-1) ->raw(function ($collection) use ($filters, $cols) ..
I am having multiple forms as collection and needs to validate their ids in one request for which i am taking from*name as name of forms and form id wrt to it. but i am not able to validate form_id wrt to formname provided. any idea to achive this would be very grateful. $v = ..
I am new to mongodb and using the aggregate function to fetch some records Query I used is: $records = $this->raw()->aggregate([ [‘$match’ => ["ts" => [‘$gte’=> $startTime,’$lt’=> $endTime]]], [‘$group’ => ["_id" =>["config" => ‘$conf’, "status" => ‘$s’ ], "count" =>[‘$sum’ =>1]], "ts" => [ ‘$dateToString’ => [ ‘format’ => ‘%Y-%m-%d’, ‘date’ => $startTime, ‘timezone’ => ..
It must be a very stupid question but I am unable to fetch a date key in the mongo aggregate function in laravel framework I used this query to fetch the records but I am not getting how to store the "ts" key in the records too. $records = $this->raw()->aggregate([ [‘$match’ => ["ts" => [‘$gte’=> ..
I’m trying to crear a seeder on laravel 6 using mongodb this is database.php use IlluminateSupportStr; return [ ‘default’ => env(‘DB_CONNECTION’), ‘connections’ => [ ‘mongodb’ => [ ‘driver’ => ‘mongodb’, ‘host’ => env(‘DB_HOST’), ‘port’ => env(‘DB_PORT’), ‘database’ => env(‘DB_DATABASE’), ‘username’ => env(‘DB_USERNAME’), ‘password’ => env(‘DB_PASSWORD’), ‘options’ => [ ‘database’ => ‘mydb’ ] ], ], and ..
I am working on a project using Laravel and MongoDB from jenssegers/laravel-mongodb package and I am struggling with crud operations on cart. Before changing the database to a NoSQL one, my functions were working, it was searching the product in my products table by id and adding, removing or updating as the case may be. ..
hello so this is my first laravel project and i’m lost.. i have a mongodb database that has a users collection and a posts collection this is my Post model: <?php namespace AppModels; use IlluminateDatabaseEloquentFactoriesHasFactory; use IlluminateDatabaseEloquentModel; use JenssegersMongodbEloquentSoftDeletes; /** * @method static create(array $array) * @method static firstWhere(string $string, int $id) */ class Post ..
I tried to create a mongodb logging channel ‘mongo’ => [ ‘driver’ => ‘monolog’, ‘handler’ => MonologHandlerMongoDBHandler::class, ‘formatter’ => MonologFormatterMongoDBFormatter::class, ‘handler_with’ => [ ‘mongo’ => new MongoDBClient("mongodb://localhost:27017"), ‘database’ => ‘testdb’, ‘collection’ => ‘testcoll’ ] ], However, im getting error: IlluminateContractsContainerBindingResolutionException(code: 0): Unresolvable dependency resolving [Parameter #0 [ <required> $mongodb ]] in class MonologHandlerMongoDBHandler The error ..
this code working fine when i not change j.acc_no value, If we change j.acc_no value it does not update the document. any one suggest any idea to fix this $updateData = [ ‘bank.$[i].details.$[j].acc_name’ => ‘raja K’, ‘bank.$[i].details.$[j].acc_no’ => ‘35252555’, ‘bank.$[i].details.$[j].min_deposit’ => ‘10000’, ‘bank.$[i].details.$[j].max_deposit’ => ‘1000000’, ‘bank.$[i].details.$[j].status’ => 1, ]; $filters = [ [‘i.bankname_slug’ => [‘$eq’ ..
I have an array(or collection) like this for my notifications. Each notification has an array field for all users who has seen the notification. array:2 [ 0 => array:8 [ "_id" => "604485ddf92e0000050079c6" "title" => "Notification title" "message" => "Notification message" "type" => "success" "expire_date" => "2021-05-09T19:30:00.000000Z" "read_by_users" => array:2 [ 0 => array:2 [ ..
Let’s say I declared a variable $a = "users" and I know there is a collection named users in my mongodb. How can I fetch the collection’s instance in folders like commands? I used Schema facade but it only returns the collection info or it can return if collection exists. Sourc..
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 to relationship with user. When I use $post->user, I always get null. Despite the fact that when ..
I’m trying to setup MongoDB in a Laravel Jetstream + Sail. What I’m doing is trying to install the following packages: mongodb/mongodb jenssegers/mongodb but I get the following errors : Problem 1 – jenssegers/mongodb[v3.8.0, …, v3.8.2] require mongodb/mongodb ^1.6 -> satisfiable by mongodb/mongodb[1.6.0, …, 1.9.x-dev (alias of dev-master)]. – mongodb/mongodb 1.9.x-dev is an alias of ..
i have a lumen project that is using mongo db now i want to access the data and do some logic on them my object in mongo is like below : _id: ObjectId(‘602cfb30bc865100073f0e56’), serviceType: ‘normal’, segment: ‘Basic’, steps: { ‘step1’: 1, ‘step2’: 2 } nnow in my laravel application i do it like below : ..
I would like to save the following object to a field on a mongodb collection via eloquent "project_settings" : { "resource" : true, "zone" : true, "contractor" : true, "responsible_person" : false } this is my php code: return ProjectModel::where($project_id)->first()->update($project_data); dont worry about the model it works fine i need to make a query that ..
I am running following query in mongodb collection and I am using this package https://github.com/jenssegers/laravel-mongodb to communicate with mongodb in laravel. $ibQuery = $this->model->project([‘message_count’ => [ ‘$size’ => [ ‘$ifNull’ => [‘$messages’, []] ] ] ]) ->get(); return $ibQuery; and I am getting this error. exception: "MongoDBDriverExceptionCommandException" file: "/opt/lampp/htdocs/my-project/vendor/mongodb/mongodb/src/Operation/Find.php" line: 337 message: "Unsupported projection option: ..
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 tells me, but when I try to add the ..

i have data in mongodb it is a road object that has a property and an array of points that it consists of: my model in laravel <?php namespace AppModels; use AppTraitsUuids; use GraphQLTypeDefinitionType; use RebingGraphQLSupportFacadesGraphQL; use JenssegersMongodbEloquentModel as Eloquent; class Road extends Eloquent { //use HasFactory; use Uuids; protected $connection = ‘mongodb’; protected $collection ..
I get wrong date from MongoDB using Eloquent in Laravel. My record in database looks like this "created_at" : ISODate("2020-11-17T15:30:42.131+01:00") Code to get records from MongoDB $taskObj = TaskComments::where(‘task_id’, $task_id)->get()->toArray(); Result date for created_at is 1970-01-25 20:31:23 which is wrong, I would like to get in this format 2020-11-17 15:30:42 I would like to create ..
When using Laravel with Jenssegers/MongoDB and Cashier, I receive the error: Call to a member function prepare() on null. Sourc..