File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -771,4 +771,29 @@ public function refresh()
771
771
772
772
return $ this ;
773
773
}
774
+
775
+ /**
776
+ * Determine if two models have the same ID and belong to the same table.
777
+ *
778
+ * @param \Illuminate\Database\Eloquent\Model|null $model
779
+ * @return bool
780
+ */
781
+ public function is ($ model )
782
+ {
783
+ $ modelKey = $ model ?->getKey();
784
+ $ currentKey = $ this ->getKey ();
785
+
786
+ if ($ modelKey instanceof \MongoDB \BSON \ObjectId) {
787
+ $ modelKey = (string ) $ modelKey ;
788
+ }
789
+
790
+ if ($ currentKey instanceof \MongoDB \BSON \ObjectId) {
791
+ $ currentKey = (string ) $ currentKey ;
792
+ }
793
+
794
+ return ! is_null ($ model ) &&
795
+ $ currentKey === $ modelKey &&
796
+ $ this ->getTable () === $ model ->getTable () &&
797
+ $ this ->getConnectionName () === $ model ->getConnectionName ();
798
+ }
774
799
}
You can’t perform that action at this time.
0 commit comments