File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/Jenssegers/Mongodb/Relations Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -199,14 +199,21 @@ public function count()
199199 /**
200200 * Indicate if a model is already contained in the embedded documents
201201 *
202- * @param \Illuminate\Database\Eloquent\Model $model
202+ * @param mixed $key
203203 * @return bool
204204 */
205- public function contains (Model $ model )
205+ public function contains ($ key )
206206 {
207+ if ($ key instanceof Model)
208+ {
209+ $ key = $ key ->getKey ();
210+ }
211+
212+ $ primaryKey = $ this ->related ->getKeyName ();
213+
207214 foreach ($ this ->getEmbeddedRecords () as $ record )
208215 {
209- if ($ record [$ model -> getKeyName () ] == $ model -> getKey () ) return true ;
216+ if ($ record [$ primaryKey ] == $ key ) return true ;
210217 }
211218
212219 return false ;
You can’t perform that action at this time.
0 commit comments