Skip to content

Commit

Permalink
Ability to replace primaryKey field via config
Browse files Browse the repository at this point in the history
Example:
$this->Crud->action()->setConfig('primaryKey', 'uuid');
  • Loading branch information
asgraf authored Oct 24, 2023
1 parent 39a7cff commit 14081ad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Traits/FindMethodTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ protected function _findRecord(?string $id, Subject $subject): EntityInterface

[$finder, $options] = $this->_extractFinder();
$query = $repository->find($finder, $options);
$primaryKey = $this->getConfig('primaryKey', $repository->getPrimaryKey());
/**
* @psalm-suppress PossiblyInvalidArgument
* @psalm-suppress InvalidArrayOffset
*/
$query->where([current($query->aliasField($repository->getPrimaryKey())) => $id]);
$query->where([current($query->aliasField($primaryKey)) => $id]);

$subject->set([
'repository' => $repository,
Expand Down

0 comments on commit 14081ad

Please sign in to comment.