Skip to content

Commit 78d7cbd

Browse files
authored
Merge pull request #1 from jenssegers/master
merge from upstream
2 parents 1d2807b + a8918ac commit 78d7cbd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1468
-967
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: jenssegers
2+
open_collective: laravel-mongodb

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ composer.lock
77
*.sublime-workspace
88
*.project
99
.idea/
10+
.phpunit.result.cache

.travis.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1-
sudo: required
2-
dist: trusty
3-
language: php
4-
php:
5-
- "7.2"
6-
- "7.1"
1+
language: minimal
2+
3+
matrix:
4+
include:
5+
- name: "7.1"
6+
env: PHP_VERSION=7.1
7+
- name: "7.2"
8+
env: PHP_VERSION=7.2
9+
- name: "7.3"
10+
env: PHP_VERSION=7.3
711

812
services:
913
- docker
1014

15+
cache:
16+
directories:
17+
- $HOME/.composer/cache
18+
1119
install:
1220
- docker version
1321
- sudo pip install docker-compose
1422
- docker-compose version
15-
- sed -i -e "s/php:cli/php:${TRAVIS_PHP_VERSION}-cli/g" Dockerfile
16-
- cat Dockerfile
17-
- docker-compose build
23+
- docker-compose build --build-arg PHP_VERSION=${PHP_VERSION}
24+
- docker-compose run --rm tests composer install --no-interaction
1825

1926
script:
20-
- docker-compose up --exit-code-from php
27+
- docker-compose run --rm tests ./vendor/bin/phpunit --coverage-clover ./clover.xml

Dockerfile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
FROM php:cli
1+
ARG PHP_VERSION=7.2
2+
ARG COMPOSER_VERSION=1.8
23

3-
RUN pecl install xdebug
4+
FROM composer:${COMPOSER_VERSION}
5+
FROM php:${PHP_VERSION}-cli
46

57
RUN apt-get update && \
6-
apt-get install -y autoconf pkg-config libssl-dev git && \
7-
pecl install mongodb git zlib1g-dev && docker-php-ext-enable mongodb && \
8-
docker-php-ext-install -j$(nproc) pdo pdo_mysql zip && docker-php-ext-enable xdebug
8+
apt-get install -y autoconf pkg-config libssl-dev git libzip-dev zlib1g-dev && \
9+
pecl install mongodb && docker-php-ext-enable mongodb && \
10+
pecl install xdebug && docker-php-ext-enable xdebug && \
11+
docker-php-ext-install -j$(nproc) pdo_mysql zip
912

10-
RUN curl -sS https://getcomposer.org/installer | php \
11-
&& mv composer.phar /usr/local/bin/ \
12-
&& ln -s /usr/local/bin/composer.phar /usr/local/bin/composer
13+
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
1314

14-
ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}"
15+
WORKDIR /code

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ composer require jenssegers/mongodb
4343
5.4.x | 3.2.x
4444
5.5.x | 3.3.x
4545
5.6.x | 3.4.x
46+
5.7.x | 3.4.x
47+
5.8.x | 3.5.x
48+
6.0.x | 3.6.x
4649

4750
And add the service provider in `config/app.php`:
4851

@@ -63,8 +66,10 @@ The service provider will register a mongodb database extension with the origina
6366
For usage outside Laravel, check out the [Capsule manager](https://github.com/illuminate/database/blob/master/README.md) and add:
6467

6568
```php
66-
$capsule->getDatabaseManager()->extend('mongodb', function($config)
69+
$capsule->getDatabaseManager()->extend('mongodb', function($config, $name)
6770
{
71+
$config['name'] = $name;
72+
6873
return new Jenssegers\Mongodb\Connection($config);
6974
});
7075
```
@@ -298,7 +303,7 @@ This service provider will slightly modify the internal DatabaseReminderReposito
298303

299304
### Queues
300305

301-
If you want to use MongoDB as your database backend, change the the driver in `config/queue.php`:
306+
If you want to use MongoDB as your database backend, change the driver in `config/queue.php`:
302307

303308
```php
304309
'connections' => [
@@ -480,7 +485,7 @@ User::where('name', 'Jaques')->decrement('weight', 50);
480485
The number of updated objects is returned:
481486

482487
```php
483-
$count = User->increment('age');
488+
$count = User::increment('age');
484489
```
485490

486491
You may also specify additional columns to update:
@@ -545,13 +550,13 @@ User::where('name', 'regex', new \MongoDB\BSON\Regex("/.*doe/i"))->get();
545550
**NOTE:** you can also use the Laravel regexp operations. These are a bit more flexible and will automatically convert your regular expression string to a MongoDB\BSON\Regex object.
546551

547552
```php
548-
User::where('name', 'regexp', '/.*doe/i'))->get();
553+
User::where('name', 'regexp', '/.*doe/i')->get();
549554
```
550555

551556
And the inverse:
552557

553558
```php
554-
User::where('name', 'not regexp', '/.*doe/i'))->get();
559+
User::where('name', 'not regexp', '/.*doe/i')->get();
555560
```
556561

557562
**Type**
@@ -689,7 +694,7 @@ For more information about model manipulation, check http://laravel.com/docs/elo
689694

690695
### Dates
691696

692-
Eloquent allows you to work with Carbon/DateTime objects instead of MongoDate objects. Internally, these dates will be converted to MongoDate objects when saved to the database. If you wish to use this functionality on non-default date fields you will need to manually specify them as described here: http://laravel.com/docs/eloquent#date-mutators
697+
Eloquent allows you to work with Carbon/DateTime objects instead of MongoDate objects. Internally, these dates will be converted to MongoDate objects when saved to the database. If you wish to use this functionality on non-default date fields, you will need to manually specify them as described here: http://laravel.com/docs/eloquent#date-mutators
693698

694699
Example:
695700

@@ -787,7 +792,7 @@ class User extends Eloquent {
787792
}
788793
```
789794

790-
You access the embedded models through the dynamic property:
795+
You can access the embedded models through the dynamic property:
791796

792797
```php
793798
$books = User::first()->books;
@@ -849,7 +854,7 @@ Embedded relations will return a Collection of embedded items instead of a query
849854

850855
### EmbedsOne Relations
851856

852-
The embedsOne relation is similar to the EmbedsMany relation, but only embeds a single model.
857+
The embedsOne relation is similar to the embedsMany relation, but only embeds a single model.
853858

854859
```php
855860
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
@@ -864,7 +869,7 @@ class Book extends Eloquent {
864869
}
865870
```
866871

867-
You access the embedded models through the dynamic property:
872+
You can access the embedded models through the dynamic property:
868873

869874
```php
870875
$author = Book::first()->author;
@@ -1014,7 +1019,7 @@ DB::collection('items')->paginate($limit, $projections);
10141019

10151020
**Push**
10161021

1017-
Add an items to an array.
1022+
Add items to an array.
10181023

10191024
```php
10201025
DB::collection('users')->where('name', 'John')->push('items', 'boots');

composer.json

Lines changed: 59 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,59 @@
1-
{
2-
"name": "jenssegers/mongodb",
3-
"description": "A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)",
4-
"keywords": ["laravel","eloquent","mongodb","mongo","database","model","moloquent"],
5-
"homepage": "https://github.com/jenssegers/laravel-mongodb",
6-
"authors": [
7-
{
8-
"name": "Jens Segers",
9-
"homepage": "https://jenssegers.com"
10-
}
11-
],
12-
"license" : "MIT",
13-
"require": {
14-
"illuminate/support": "^5.6",
15-
"illuminate/container": "^5.6",
16-
"illuminate/database": "^5.6",
17-
"illuminate/events": "^5.6",
18-
"mongodb/mongodb": "^1.0.0"
19-
},
20-
"require-dev": {
21-
"phpunit/phpunit": "^6.0|^7.0",
22-
"orchestra/testbench": "^3.1",
23-
"mockery/mockery": "^1.0",
24-
"satooshi/php-coveralls": "^2.0",
25-
"doctrine/dbal": "^2.5"
26-
},
27-
"autoload": {
28-
"psr-0": {
29-
"Jenssegers\\Mongodb": "src/"
30-
}
31-
},
32-
"autoload-dev": {
33-
"classmap": [
34-
"tests/TestCase.php",
35-
"tests/models",
36-
"tests/seeds"
37-
]
38-
},
39-
"suggest": {
40-
"jenssegers/mongodb-session": "Add MongoDB session support to Laravel-MongoDB",
41-
"jenssegers/mongodb-sentry": "Add Sentry support to Laravel-MongoDB"
42-
},
43-
"extra": {
44-
"laravel": {
45-
"providers": [
46-
"Jenssegers\\Mongodb\\MongodbServiceProvider",
47-
"Jenssegers\\Mongodb\\MongodbQueueServiceProvider"
48-
]
49-
}
50-
}
51-
}
1+
{
2+
"name": "jenssegers/mongodb",
3+
"description": "A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)",
4+
"keywords": [
5+
"laravel",
6+
"eloquent",
7+
"mongodb",
8+
"mongo",
9+
"database",
10+
"model",
11+
"moloquent"
12+
],
13+
"homepage": "https://github.com/jenssegers/laravel-mongodb",
14+
"authors": [
15+
{
16+
"name": "Jens Segers",
17+
"homepage": "https://jenssegers.com"
18+
}
19+
],
20+
"license": "MIT",
21+
"require": {
22+
"illuminate/support": "^5.8|^6.0",
23+
"illuminate/container": "^5.8|^6.0",
24+
"illuminate/database": "^5.8|^6.0",
25+
"illuminate/events": "^5.8|^6.0",
26+
"mongodb/mongodb": "^1.4"
27+
},
28+
"require-dev": {
29+
"phpunit/phpunit": "^6.0|^7.0|^8.0",
30+
"orchestra/testbench": "^3.1|^4.0",
31+
"mockery/mockery": "^1.0",
32+
"satooshi/php-coveralls": "^2.0",
33+
"doctrine/dbal": "^2.5"
34+
},
35+
"autoload": {
36+
"psr-0": {
37+
"Jenssegers\\Mongodb": "src/"
38+
}
39+
},
40+
"autoload-dev": {
41+
"classmap": [
42+
"tests/TestCase.php",
43+
"tests/models",
44+
"tests/seeds"
45+
]
46+
},
47+
"suggest": {
48+
"jenssegers/mongodb-session": "Add MongoDB session support to Laravel-MongoDB",
49+
"jenssegers/mongodb-sentry": "Add Sentry support to Laravel-MongoDB"
50+
},
51+
"extra": {
52+
"laravel": {
53+
"providers": [
54+
"Jenssegers\\Mongodb\\MongodbServiceProvider",
55+
"Jenssegers\\Mongodb\\MongodbQueueServiceProvider"
56+
]
57+
}
58+
}
59+
}

docker-compose.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
version: '3'
22

33
services:
4-
5-
php:
6-
container_name: php
4+
tests:
5+
container_name: tests
76
build:
87
context: .
98
dockerfile: Dockerfile
109
volumes:
1110
- .:/code
1211
working_dir: /code
13-
command: bash -c "composer install --prefer-source --no-interaction && php ./vendor/bin/phpunit"
1412
depends_on:
15-
- mysql
1613
- mongodb
14+
- mysql
1715

1816
mysql:
1917
container_name: mysql
20-
image: mysql
18+
image: mysql:5.7
2119
environment:
2220
MYSQL_ROOT_PASSWORD:
2321
MYSQL_DATABASE: unittest
@@ -28,5 +26,7 @@ services:
2826
mongodb:
2927
container_name: mongodb
3028
image: mongo
29+
ports:
30+
- 27017:27017
3131
logging:
3232
driver: none

phpunit.xml.dist

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,46 @@
77
convertNoticesToExceptions="true"
88
convertWarningsToExceptions="true"
99
processIsolation="false"
10-
stopOnFailure="false"
11-
syntaxCheck="false"
12-
verbose="true"
13-
>
10+
stopOnFailure="false">
1411
<testsuites>
1512
<testsuite name="all">
1613
<directory>tests/</directory>
17-
<exclude>tests/MysqlRelationsTest.php</exclude>
1814
</testsuite>
1915
<testsuite name="schema">
20-
<directory>tests/SchemaTest.php</directory>
16+
<file>tests/SchemaTest.php</file>
2117
</testsuite>
2218
<testsuite name="seeder">
23-
<directory>tests/SeederTest.php</directory>
19+
<file>tests/SeederTest.php</file>
2420
</testsuite>
2521
<testsuite name="cache">
26-
<directory>tests/CacheTest.php</directory>
22+
<file>tests/CacheTest.php</file>
2723
</testsuite>
2824
<testsuite name="builder">
29-
<directory>tests/QueryBuilderTest.php</directory>
30-
<directory>tests/QueryTest.php</directory>
25+
<file>tests/QueryBuilderTest.php</file>
26+
<file>tests/QueryTest.php</file>
3127
</testsuite>
3228
<testsuite name="model">
33-
<directory>tests/ModelTest.php</directory>
34-
<directory>tests/RelationsTest.php</directory>
29+
<file>tests/ModelTest.php</file>
30+
<file>tests/RelationsTest.php</file>
3531
</testsuite>
3632
<testsuite name="relations">
37-
<directory>tests/RelationsTest.php</directory>
38-
<directory>tests/EmbeddedRelationsTest.php</directory>
33+
<file>tests/RelationsTest.php</file>
34+
<file>tests/EmbeddedRelationsTest.php</file>
3935
</testsuite>
4036
<testsuite name="mysqlrelations">
41-
<directory>tests/RelationsTest.php</directory>
42-
<directory>tests/MysqlRelationsTest.php</directory>
37+
<file>tests/RelationsTest.php</file>
4338
</testsuite>
4439
<testsuite name="validation">
45-
<directory>tests/ValidationTest.php</directory>
40+
<file>tests/ValidationTest.php</file>
4641
</testsuite>
4742
</testsuites>
43+
<php>
44+
<env name="MONGO_HOST" value="mongodb"/>
45+
<env name="MONGO_DATABASE" value="unittest"/>
46+
<env name="MONGO_PORT" value="27017"/>
47+
<env name="MYSQL_HOST" value="mysql"/>
48+
<env name="MYSQL_DATABASE" value="unittest"/>
49+
<env name="MYSQL_USERNAME" value="root"/>
50+
<env name="QUEUE_CONNECTION" value="database"/>
51+
</php>
4852
</phpunit>

0 commit comments

Comments
 (0)