diff --git a/src/Database/Eloquent/FMEloquentBuilder.php b/src/Database/Eloquent/FMEloquentBuilder.php index a173b4b..42325ef 100644 --- a/src/Database/Eloquent/FMEloquentBuilder.php +++ b/src/Database/Eloquent/FMEloquentBuilder.php @@ -167,6 +167,11 @@ public function editRecord() } } + // set the ModID if that option is set on the model + if ($model->withModId()) { + $this->query->modId($model->getModId()); + } + if ($fieldsToWrite->count() > 0 || count($modifiedPortals) > 0) { // we have some regular text fields to update // forward this request to a base query builder to execute the edit record request diff --git a/src/Database/Eloquent/FMModel.php b/src/Database/Eloquent/FMModel.php index 47644a4..47ab340 100644 --- a/src/Database/Eloquent/FMModel.php +++ b/src/Database/Eloquent/FMModel.php @@ -65,6 +65,8 @@ abstract class FMModel extends Model */ protected $modId; + protected $useModId = false; + /** * The "type" of the primary key ID. FileMaker uses UUID strings by default. * @@ -219,6 +221,17 @@ public function setModId($modId): void $this->modId = $modId; } + /** + * Include the modification Id when editing a record + */ + public function withModId($include = true): self + { + // remove any set ModId if the user wishes to remove it + $this->useModId = $include; + + return $this; + } + public function getReadOnlyFields() { return $this->readOnlyFields;