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

Allow setting custom primary keys #469

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
22 changes: 18 additions & 4 deletions src/Generators/FactoryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,32 @@
class FactoryGenerator extends EntityGenerator
{
/**
* Generate, and return the attribute.
* The primary key methods.
*
* @var string[]
*/
private static $methods = ['getKey', 'pk'];
private static $methods;

/**
* The factory properties.
* The primary key properties.
*
* @var string[]
*/
private static $properties = ['id', '_id', 'Id'];
private static $properties;

/**
* Create a new factory generator instance.
*
* @param string[]|null $methods The primary key methods.
* @param string[]|null $properties The primary key properties.
*
* @return void
*/
public function __construct(array $methods = null, array $properties = null)
{
$this->methods = $methods ?: ['getKey', 'pk'];
$this->properties = $properties ?: ['id', '_id', 'Id'];
}

/**
* Generate, and return the attribute.
Expand Down