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 2727 }
2828 },
2929 "require" : {
30- "php" : " ^ 7.2.5 || ^8.0 " ,
30+ "php" : " >= 7.2" ,
3131 "illuminate/support" : " ^7.0 || ^8.0" ,
3232 "illuminate/database" : " ^7.0 || ^8.0" ,
3333 "illuminate/http" : " ^7.0 || ^8.0" ,
Original file line number Diff line number Diff line change @@ -250,7 +250,7 @@ public function createRecord()
250250 */
251251 public function update (array $ values )
252252 {
253- return $ this ->editRecord ( );
253+ return $ this ->toBase ()-> update ( $ values );
254254 }
255255
256256 protected function getModIdFromFmResponse ($ response )
Original file line number Diff line number Diff line change @@ -564,6 +564,21 @@ public function duplicate(int $recordId): array
564564 return $ response ;
565565 }
566566
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+
567582 public function layout ($ layoutName )
568583 {
569584 $ this ->from ($ layoutName );
Original file line number Diff line number Diff line change @@ -330,6 +330,33 @@ public function editRecord(FMBaseBuilder $query)
330330 return $ response ;
331331 }
332332
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+
333360 /**
334361 * @param FMBaseBuilder $query
335362 * @return bool
You can’t perform that action at this time.
0 commit comments