Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added withModId function #83

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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->usingModId()) {
$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
18 changes: 18 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,22 @@ public function setModId($modId): void
$this->modId = $modId;
}

/**
* Include the modification Id when editing a record
*/
public function withModId($include = true): static
{
// remove any set ModId if the user wishes to remove it
$this->useModId = $include;

return $this;
}

Smef marked this conversation as resolved.
Show resolved Hide resolved
public function usingModId(): bool
{
return $this->useModId;
}

public function getReadOnlyFields()
{
return $this->readOnlyFields;
Expand Down
Loading