Commit 2b8a37f2 authored by Jens Segers's avatar Jens Segers

Merge branch 'develop'

parents a42f9459 2862e2ed
language: php
php:
- 5.3
- 5.4
- 5.5
......
......@@ -250,6 +250,22 @@ You may also specify additional columns to update:
User::where('age', '29')->increment('age', 1, array('group' => 'thirty something'));
User::where('bmi', 30)->decrement('bmi', 1, array('category' => 'overweight'));
**Soft deleting**
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:
use Jenssegers\Mongodb\Eloquent\SoftDeletingTrait;
class User extends Eloquent {
use SoftDeletingTrait;
protected $dates = ['deleted_at'];
}
For more information check http://laravel.com/docs/eloquent#soft-deleting
### MongoDB specific operators
**Exists**
......
......@@ -10,13 +10,14 @@
],
"license" : "MIT",
"require": {
"php": ">=5.3.0",
"illuminate/support": "4.1.*",
"illuminate/database": "4.1.*",
"illuminate/events": "4.1.*"
"php": ">=5.4.0",
"illuminate/support": "4.2.x-dev",
"illuminate/container": "4.2.x-dev",
"illuminate/database": "4.2.x-dev",
"illuminate/events": "4.2.x-dev"
},
"require-dev": {
"orchestra/testbench": "2.1.*",
"orchestra/testbench": "*",
"mockery/mockery": "*"
},
"autoload": {
......
<?php namespace Jenssegers\Mongodb\Eloquent;
trait SoftDeletingTrait {
use \Illuminate\Database\Eloquent\SoftDeletingTrait;
/**
* Get the fully qualified "deleted at" column.
*
* @return string
*/
public function getQualifiedDeletedAtColumn()
{
return $this->getDeletedAtColumn();
}
}
......@@ -181,16 +181,6 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
return new MongoDate;
}
/**
* Get the fully qualified "deleted at" column.
*
* @return string
*/
public function getQualifiedDeletedAtColumn()
{
return $this->getDeletedAtColumn();
}
/**
* Get the table associated with the model.
*
......@@ -242,11 +232,6 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
{
$value = (string) $value;
}
else if ($value instanceof MongoDate)
{
$value = $this->asDateTime($value)->format($this->getDateFormat());
}
}
return $attributes;
......
......@@ -332,8 +332,8 @@ class ModelTest extends TestCase {
// test custom date format for json output
$json = $user->toArray();
$this->assertEquals($user->birthday->format('l jS \of F Y h:i:s A'), $json['birthday']);
$this->assertEquals($user->created_at->format('l jS \of F Y h:i:s A'), $json['created_at']);
$this->assertEquals((string) $user->birthday, $json['birthday']);
$this->assertEquals((string) $user->created_at, $json['created_at']);
// test default date format for json output
$item = Item::create(array('name' => 'sword'));
......
<?php
use Jenssegers\Mongodb\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletingTrait;
class Soft extends Eloquent {
use SoftDeletingTrait;
protected $collection = 'soft';
protected $softDelete = true;
protected $dates = array('deleted_at');
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment