66use BlueFeather \EloquentFileMaker \Database \Eloquent \Concerns \FMHasRelationships ;
77use BlueFeather \EloquentFileMaker \Database \Query \FMBaseBuilder ;
88use BlueFeather \EloquentFileMaker \Exceptions \FileMakerDataApiException ;
9+ use Illuminate \Contracts \Support \Arrayable ;
910use Illuminate \Database \Eloquent \Builder ;
1011use Illuminate \Pagination \Paginator ;
1112use Illuminate \Support \Collection ;
@@ -101,17 +102,6 @@ public function doesntExist()
101102 }
102103
103104
104- /**
105- * Add a where clause on the primary key to the query.
106- *
107- * @param mixed $id
108- * @return $this
109- */
110- public function whereKey ($ id )
111- {
112- return $ this ->where ($ this ->model ->getKeyName (), $ id );
113- }
114-
115105 /**
116106 * Add a where clause on the primary key to the query.
117107 *
@@ -120,19 +110,28 @@ public function whereKey($id)
120110 */
121111 public function whereKeyNot ($ id )
122112 {
123- return $ this ->where ($ this ->model ->getKeyName (), $ id )->omit ();
124- }
125113
114+ if (is_array ($ id ) || $ id instanceof Arrayable) {
115+ $ this ->query ->whereNotIn ($ this ->model ->getQualifiedKeyName (), $ id );
126116
127- /** Find a model by its primary key
128- *
129- * @param $id
130- */
131- public function find ($ id , $ columns = ['* ' ])
132- {
133- return $ this ->where ($ this ->model ->getKeyName (), $ id )->first ();
117+ return $ this ;
118+ }
119+
120+ if ($ id !== null && $ this ->model ->getKeyType () === 'string ' ) {
121+ $ id = (string ) $ id ;
122+ }
123+
124+ // If this is our first where clause we can add the omit directly
125+ if (sizeof ($ this ->wheres ) === 0 ){
126+ return $ this ->where ($ this ->model ->getKeyName (), $ id )->omit ();
127+ }
128+
129+ // otherwise we need to add a find and omit
130+ return $ this ->orWhere ($ this ->model ->getKeyName (), $ id )->omit ();
134131 }
135132
133+
134+
136135 public function findByRecordId ($ recordId )
137136 {
138137 $ response = $ this ->query ->findByRecordId ($ recordId );
0 commit comments