Skip to content

Commit bcde12c

Browse files
author
David Nahodyl
committed
Merge branch 'dev'
2 parents 0b224a9 + 097b23f commit bcde12c

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
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",

src/Database/Eloquent/FMEloquentBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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)

src/Database/Query/FMBaseBuilder.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff 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);

src/Services/FileMakerConnection.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)