Skip to content

Commit 0a7519a

Browse files
authored
Merge pull request #83 from gearbox-solutions/feature/add-modId
added withModId function
2 parents 3487422 + f1545c7 commit 0a7519a

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/Database/Eloquent/FMEloquentBuilder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ public function editRecord()
167167
}
168168
}
169169

170+
// set the ModID if that option is set on the model
171+
if ($model->usingModId()) {
172+
$this->query->modId($model->getModId());
173+
}
174+
170175
if ($fieldsToWrite->count() > 0 || count($modifiedPortals) > 0) {
171176
// we have some regular text fields to update
172177
// forward this request to a base query builder to execute the edit record request

src/Database/Eloquent/FMModel.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ abstract class FMModel extends Model
6565
*/
6666
protected $modId;
6767

68+
protected $useModId = false;
69+
6870
/**
6971
* The "type" of the primary key ID. FileMaker uses UUID strings by default.
7072
*
@@ -219,6 +221,22 @@ public function setModId($modId): void
219221
$this->modId = $modId;
220222
}
221223

224+
/**
225+
* Include the modification Id when editing a record
226+
*/
227+
public function withModId($include = true): static
228+
{
229+
// remove any set ModId if the user wishes to remove it
230+
$this->useModId = $include;
231+
232+
return $this;
233+
}
234+
235+
public function usingModId(): bool
236+
{
237+
return $this->useModId;
238+
}
239+
222240
public function getReadOnlyFields()
223241
{
224242
return $this->readOnlyFields;

0 commit comments

Comments
 (0)