Skip to content

Commit 2b8a37f

Browse files
committed
Merge branch 'develop'
2 parents a42f945 + 2862e2e commit 2b8a37f

File tree

7 files changed

+46
-25
lines changed

7 files changed

+46
-25
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
language: php
22

33
php:
4-
- 5.3
54
- 5.4
65
- 5.5
76

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,22 @@ You may also specify additional columns to update:
250250
User::where('age', '29')->increment('age', 1, array('group' => 'thirty something'));
251251
User::where('bmi', 30)->decrement('bmi', 1, array('category' => 'overweight'));
252252

253+
**Soft deleting**
254+
255+
When soft deleting a model, it is not actually removed from your database. Instead, a deleted_at timestamp is set on the record. To enable soft deletes for a model, apply the SoftDeletingTrait to the model:
256+
257+
use Jenssegers\Mongodb\Eloquent\SoftDeletingTrait;
258+
259+
class User extends Eloquent {
260+
261+
use SoftDeletingTrait;
262+
263+
protected $dates = ['deleted_at'];
264+
265+
}
266+
267+
For more information check http://laravel.com/docs/eloquent#soft-deleting
268+
253269
### MongoDB specific operators
254270

255271
**Exists**

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
],
1111
"license" : "MIT",
1212
"require": {
13-
"php": ">=5.3.0",
14-
"illuminate/support": "4.1.*",
15-
"illuminate/database": "4.1.*",
16-
"illuminate/events": "4.1.*"
13+
"php": ">=5.4.0",
14+
"illuminate/support": "4.2.x-dev",
15+
"illuminate/container": "4.2.x-dev",
16+
"illuminate/database": "4.2.x-dev",
17+
"illuminate/events": "4.2.x-dev"
1718
},
1819
"require-dev": {
19-
"orchestra/testbench": "2.1.*",
20+
"orchestra/testbench": "*",
2021
"mockery/mockery": "*"
2122
},
2223
"autoload": {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php namespace Jenssegers\Mongodb\Eloquent;
2+
3+
trait SoftDeletingTrait {
4+
5+
use \Illuminate\Database\Eloquent\SoftDeletingTrait;
6+
7+
/**
8+
* Get the fully qualified "deleted at" column.
9+
*
10+
* @return string
11+
*/
12+
public function getQualifiedDeletedAtColumn()
13+
{
14+
return $this->getDeletedAtColumn();
15+
}
16+
17+
}

src/Jenssegers/Mongodb/Model.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,6 @@ public function freshTimestamp()
181181
return new MongoDate;
182182
}
183183

184-
/**
185-
* Get the fully qualified "deleted at" column.
186-
*
187-
* @return string
188-
*/
189-
public function getQualifiedDeletedAtColumn()
190-
{
191-
return $this->getDeletedAtColumn();
192-
}
193-
194184
/**
195185
* Get the table associated with the model.
196186
*
@@ -242,11 +232,6 @@ public function attributesToArray()
242232
{
243233
$value = (string) $value;
244234
}
245-
246-
else if ($value instanceof MongoDate)
247-
{
248-
$value = $this->asDateTime($value)->format($this->getDateFormat());
249-
}
250235
}
251236

252237
return $attributes;

tests/ModelTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ public function testDates()
332332

333333
// test custom date format for json output
334334
$json = $user->toArray();
335-
$this->assertEquals($user->birthday->format('l jS \of F Y h:i:s A'), $json['birthday']);
336-
$this->assertEquals($user->created_at->format('l jS \of F Y h:i:s A'), $json['created_at']);
335+
$this->assertEquals((string) $user->birthday, $json['birthday']);
336+
$this->assertEquals((string) $user->created_at, $json['created_at']);
337337

338338
// test default date format for json output
339339
$item = Item::create(array('name' => 'sword'));

tests/models/Soft.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<?php
22

33
use Jenssegers\Mongodb\Model as Eloquent;
4+
use Jenssegers\Mongodb\Eloquent\SoftDeletingTrait;
45

56
class Soft extends Eloquent {
67

8+
use SoftDeletingTrait;
9+
710
protected $collection = 'soft';
8-
protected $softDelete = true;
11+
protected $dates = array('deleted_at');
912

10-
}
13+
}

0 commit comments

Comments
 (0)