File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
src/Jenssegers/Mongodb/Relations Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -186,6 +186,16 @@ public function save(Model $model)
186186 return false ;
187187 }
188188
189+ /**
190+ * Get the number of embedded documents.
191+ *
192+ * @return int
193+ */
194+ public function count ()
195+ {
196+ return count ($ this ->getEmbeddedRecords ());
197+ }
198+
189199 /**
190200 * Attach a model instance to the parent model without persistence.
191201 *
Original file line number Diff line number Diff line change @@ -327,6 +327,7 @@ public function testEmbedsManySave()
327327 $ this ->assertEquals (2 , count ($ user ->addresses ));
328328 $ this ->assertEquals (2 , count ($ user ->addresses ()->get ()));
329329 $ this ->assertEquals (2 , $ user ->addresses ->count ());
330+ $ this ->assertEquals (2 , $ user ->addresses ()->count ());
330331 $ this ->assertEquals (array ('London ' , 'New York ' ), $ user ->addresses ->lists ('city ' ));
331332
332333 $ freshUser = User::find ($ user ->_id );
You can’t perform that action at this time.
0 commit comments