Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

This code was written to accompany [this tutorial article](https://www.mongodb.com/developer/languages/php/laravel-mongodb-tutorial/?utm_campaign=devrel).


## Prerequisites
You'll need the following installed on your computer to follow along with this tutorial:

Expand Down
2 changes: 1 addition & 1 deletion src/app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class Kernel extends HttpKernel
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Http\Middleware\HandleCors::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
Expand Down
4 changes: 2 additions & 2 deletions src/app/Models/Book.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
//use Illuminate\Database\Eloquent\Model;

// use this instead of the default "Illuminate\Database\Eloquent\Model"
use Jenssegers\Mongodb\Eloquent\Model;
use MongoDB\Laravel\Eloquent\Model;

class Book extends Model
{
use HasFactory;

protected $fillable = ['title', 'author', 'isbn'];

protected $connection = 'mongodb';
Expand Down
8 changes: 4 additions & 4 deletions src/app/Models/CustomerMongoDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;

//use Illuminate\Database\Eloquent\Model;
use Jenssegers\Mongodb\Eloquent\Model;
use MongoDB\Laravel\Eloquent\Model;

class CustomerMongoDB extends Model
{
Expand All @@ -14,9 +14,9 @@ class CustomerMongoDB extends Model
// the selected database as defined in /config/database.php
protected $connection = 'mongodb';

// equivalent to $table for MySQL
protected $collection = 'laracoll';
// equivalent to $table for MySQL
protected $collection = 'laracoll';

// defines the schema's top-level properties.
protected $fillable = ['guid','first_name', 'family_name', 'email', 'address'];
protected $fillable = ['guid','first_name', 'family_name', 'email', 'address'];
}
4 changes: 2 additions & 2 deletions src/app/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//use Illuminate\Database\Eloquent\Model;

// use this instead of the default "Illuminate\Database\Eloquent\Model"
use Jenssegers\Mongodb\Eloquent\Model;
use MongoDB\Laravel\Eloquent\Model;

class Post extends Model
{
Expand All @@ -15,7 +15,7 @@ class Post extends Model
// required for MongoDB, defined in /config/database.php
protected $connection = 'mongodb';

// Normallt the table (collection in MDB lingo) would be the plural class name = "posts"
// Normallt the table (collection in MDB lingo) would be the plural class name = "posts"
// override it as follow
protected $collection = 'laracoll';

Expand Down
23 changes: 11 additions & 12 deletions src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^8.0",
"fruitcake/laravel-cors": "^2.0.5",
"php": "^8.1",
"guzzlehttp/guzzle": "^7.2",
"mongodb/laravel-mongodb": "^3.9",
"laravel/framework": "^9.0",
"laravel/sanctum": "^2.14",
"laravel/tinker": "^2.7"
"mongodb/laravel-mongodb": "4.0.0-rc1",
"laravel/framework": "^10.0",
"laravel/sanctum": "^3.3",
"laravel/tinker": "^2.8"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.23",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^6.1",
"phpunit/phpunit": "^9.5.10",
"spatie/laravel-ignition": "^1.0"
"fakerphp/faker": "^1.23",
"laravel/sail": "^1.25",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^7.8",
"phpunit/phpunit": "^10.0",
"spatie/laravel-ignition": "^2.3"
},
"autoload": {
"psr-4": {
Expand Down
Loading