File tree Expand file tree Collapse file tree 4 files changed +44
-2
lines changed Expand file tree Collapse file tree 4 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 27
27
}
28
28
},
29
29
"require" : {
30
- "php" : " ^ 7.2.5 || ^8.0 " ,
30
+ "php" : " >= 7.2" ,
31
31
"illuminate/support" : " ^7.0 || ^8.0" ,
32
32
"illuminate/database" : " ^7.0 || ^8.0" ,
33
33
"illuminate/http" : " ^7.0 || ^8.0" ,
Original file line number Diff line number Diff line change @@ -250,7 +250,7 @@ public function createRecord()
250
250
*/
251
251
public function update (array $ values )
252
252
{
253
- return $ this ->editRecord ( );
253
+ return $ this ->toBase ()-> update ( $ values );
254
254
}
255
255
256
256
protected function getModIdFromFmResponse ($ response )
Original file line number Diff line number Diff line change @@ -564,6 +564,21 @@ public function duplicate(int $recordId): array
564
564
return $ response ;
565
565
}
566
566
567
+ /**
568
+ * Update records in the database.
569
+ *
570
+ * @param array $values
571
+ * @return int
572
+ */
573
+ public function update (array $ values )
574
+ {
575
+ $ this ->applyBeforeQueryCallbacks ();
576
+
577
+ $ this ->fieldData ($ values );
578
+
579
+ return $ this ->connection ->update ($ this , null );
580
+ }
581
+
567
582
public function layout ($ layoutName )
568
583
{
569
584
$ this ->from ($ layoutName );
Original file line number Diff line number Diff line change @@ -330,6 +330,33 @@ public function editRecord(FMBaseBuilder $query)
330
330
return $ response ;
331
331
}
332
332
333
+ /**
334
+ * Attempt to emulate a sql update in FileMaker
335
+ *
336
+ * @param FMBaseBuilder $query
337
+ * @param array $bindings
338
+ * @return int
339
+ */
340
+ public function update ($ query , $ bindings = [])
341
+ {
342
+ // find the records in the find request query
343
+ $ findQuery = clone $ query ;
344
+ $ findQuery ->fieldData = null ;
345
+ $ results = $ this ->performFind ($ findQuery );
346
+
347
+ $ records = $ results ['response ' ]['data ' ];
348
+ foreach ($ records as $ record ){
349
+ // update each record
350
+ $ builder = new FMBaseBuilder ($ this );
351
+ $ builder ->recordId ($ record ['recordId ' ]);
352
+ $ builder ->fieldData = $ query ->fieldData ;
353
+ $ builder ->layout ($ query ->from );
354
+ $ builder ->editRecord ();
355
+ }
356
+
357
+ return count ($ records );
358
+ }
359
+
333
360
/**
334
361
* @param FMBaseBuilder $query
335
362
* @return bool
You can’t perform that action at this time.
0 commit comments