Skip to content

Commit

Permalink
added withModId function
Browse files Browse the repository at this point in the history
  • Loading branch information
Smef committed Oct 8, 2024
1 parent 97b91cf commit 907bd7d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Database/Eloquent/FMEloquentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions src/Database/Eloquent/FMModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 907bd7d

Please sign in to comment.