Category : mongodb

I am trying to configure a embedsMany and use this part of jenssegers/laravel-mongodb documentation: Documentation My object is get a Company from my Department Model This is my Company Model: <?php namespace AppDomainsCompanyModels; use JenssegersMongodbEloquentModel; class Company extends Model { protected $connection = ‘companies’; public function departments() { return $this->embedsMany(Department::class); } } And here is ..

Read more

I m new to MongoDB, for me I need to search the name " Raja Sekar " from name field in the database, I have indexed it. But my condition is search term should match 75 percent of similar records. Can you please help me with this db.customers.find({$text: {$search: "raja sekar kumar"}}, {score: {$meta: "textScore"}}).sort({score:{$meta:"textScore"}}) ..

Read more

I have followed the instructions on the following link: https://www.php.net/manual/en/mongodb.installation.windows.php But when i try one of the following comands: composer require jenssegers/mongodb composer require jenssegers/mongodb:dev-develop composer require jenssegers/mongodb –ignore-platform-reqs They all return the same error: Using version ^3.7 for jenssegers/mongodb ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Your ..

Read more

I am trying to connect the MongoDB database to my project in Laravel 7.0 using Docker. I have followed this guide LINK Unfortunately, not everything goes as planned. I cannot run the command php artisan migrate because an error occurs MongoDBDriverExceptionConnectionTimeoutException No suitable servers found (`serverSelectionTryOnce` set): [Invalid reply from server. calling ismaster on ‘127.0.0.1:50003’] ..

Read more

error : The SCRAM_SHA_256 authentication mechanism requires libmongoc built with ENABLE_SSL i tried to configure and in terminal i found this when i run php -i | grep mongo mongodb libmongoc bundled version => 1.16.2 libmongoc SSL => enabled libmongoc SSL library => OpenSSL libmongoc crypto => enabled libmongoc crypto library => libcrypto libmongoc crypto ..

Read more

I am doing a project with Laravel framework.I use the ‘mongodb’ as the database.I created a database seeder file for ‘user table ‘ of the database.After using the’php artisan db:seed’ commands it shows that ‘Database seeding completed successfully.’.But when I use ‘ db.users.find()’ command it does not give any collection data Userseeder.php <?php use IlluminateDatabaseSeeder; ..

Read more

Trying to make a partial search on an indexed field. I use Laravel 6.9. I ‘ve created a field for every document in my collection that consists of the data of 5 other fields seperated with a ~. For example name~surname~address~phone~mobile. I created just one field so that i can make the search faster. This ..

Read more

I have to calculate the total discount percentage(%) of the Item based on Item price and Item sales price. But column data store in mongodb collection in decimal formate like 11,000 so when performing calculation as $itemPrice = 10,000; $itemSalesPrice = 11,000; $discount = (($itemPrice – $itemSalesPriceprice) / $itemPrice) * 100; PHP returns Error as ..

Read more

I have 2 collections books and courses. I need to get courses data with the books collection when we get the books data, which is present n array form in the books collection. 1st collection Books: [ { "_id": { "$oid": "5ed0f3efcb4b0000c500462b" }, "name": "book", "guard_name": "web", "updated_at": { "$date": "2020-05-29T11:37:19.502Z" }, "created_at": { "$date": ..

Read more

I have 1st collection of users: { "_id": { "$oid": "5ed0f5bf815f000004006fa5" }, "name": "admin", "email": "[email protected]","password": "$2y$10$JxLj.sPQ.WLwE7cVHTIY3OYSar9B2OjxDzS1uQJwVmMug3mipHMVS", "updated_at": {"$date": "2020-06-02T07:41:23.052Z"}, "created_at": {"$date": "2020-05-29T11:45:03.136Z"}, "book_ids": ["5ed0f3efcb4b0000c500462b"]} 2nd collection books: [{"_id": {"$oid": "5ed0f3efcb4b0000c500462b"}, "name": "book", "guard_name": "web", "updated_at": {"$date": "2020-05-29T11:37:19.502Z"}, "created_at": {"$date": "2020-05-29T11:37:19.502Z"}, "chapter_ids": ["5ed0f3efcb4b0000c5004622", "5ed0f3efcb4b0000c5004623", "5ed0f3efcb4b0000c5004624", "5ed0f3efcb4b0000c5004625", "5ed0f3efcb4b0000c5004626", "5ed0f3efcb4b0000c5004627", "5ed0f3efcb4b0000c5004628", "5ed0f3efcb4b0000c5004629", "5ed0f3efcb4b0000c500462a"], "user_ids": ["5ed0f5bf815f000004006fa5"] }] 3rd ..

Read more

How can I filter products to existing collections? There is simple object: { “_id”: {“$oid”:”5bbf1f4497df641114467f29″}, “title”:{“en”:”Black Antonia”,”pl”:”Czarny Antonia”}, “slug”:{“en”:”black-antonia”,”pl”:”czarny-antonia”}, “collections”:{ “5cc2fc3e97df6428d951bfd7”:1, “5cc2f33097df6428d951bfd2”:1 } } There is my simple query: collect(self::select(‘_id, title, slug, collections’) ->store() // conditions ->where() // conditions […] /** How can I filter products to existing collections? */ ->get(); details: laravel 5.8 // ..

Read more

<?php namespace AppHttpControllersAuth; use AppHttpControllersController; use IlluminateHttpRequest; use AppModelCompany; use AppModelUser; use Crypt; use Hash; use IlluminateSupportFacadesAuth; class LoginController extends Controller { public function login(Request $request) { $email = $request->input(’email’); $password = $request->input(‘password’); $user = User::where(’email’, $email)->first(); if ($user) { if (! $user->is_verified) { return response()->json([‘success’ => false,’message’ => ‘User not verified.’]); } if (Auth::attempt([’email’ ..

Read more