Skip to content

Commit 82cab1e

Browse files
committed
Code style tweak
1 parent eed876e commit 82cab1e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Jenssegers/Mongodb/Model.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
5151
*/
5252
public function getIdAttribute($value)
5353
{
54-
if (!$value && array_key_exists('_id', $this->attributes)) {
54+
// If we don't have a value for 'id', we will use the Mongo '_id' value.
55+
// This allows us to work with models in a more sql-like way.
56+
if ( ! $value and array_key_exists('_id', $this->attributes))
57+
{
5558
$value = $this->attributes['_id'];
5659
}
5760

58-
// Return _id as string
59-
if ($value instanceof MongoId) {
61+
// Convert MongoId's to string.
62+
if ($value instanceof MongoId)
63+
{
6064
return (string) $value;
6165
}
6266

0 commit comments

Comments
 (0)