added account number field to user (#2671)
This commit is contained in:
@@ -56,7 +56,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
* }
|
||||
* )
|
||||
*
|
||||
* @Exporter\Order({"id", "username", "alias", "title", "email", "last_login", "language", "timezone", "active", "registeredAt", "roles", "teams"})
|
||||
* @Exporter\Order({"id", "username", "alias", "title", "email", "last_login", "language", "timezone", "active", "registeredAt", "roles", "teams", "color", "accountNumber"})
|
||||
* @Exporter\Expose("email", label="label.email", exp="object.getEmail()")
|
||||
* @Exporter\Expose("username", label="label.username", exp="object.getUsername()")
|
||||
* @Exporter\Expose("timezone", label="label.timezone", exp="object.getTimezone()")
|
||||
@@ -85,7 +85,6 @@ class User implements UserInterface, EquatableInterface, \Serializable
|
||||
* Internal ID
|
||||
*
|
||||
* @var int
|
||||
* @internal must be protected because of parent class
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
@@ -96,7 +95,7 @@ class User implements UserInterface, EquatableInterface, \Serializable
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*/
|
||||
protected $id;
|
||||
private $id;
|
||||
/**
|
||||
* The user alias will be displayed in the frontend instead of the username
|
||||
*
|
||||
@@ -227,6 +226,17 @@ class User implements UserInterface, EquatableInterface, \Serializable
|
||||
* @Assert\Email(groups={"Registration", "UserCreate", "Profile"})
|
||||
*/
|
||||
private $email;
|
||||
/**
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
*
|
||||
* @Exporter\Expose(label="label.account_number")
|
||||
*
|
||||
* @var string|null
|
||||
* @ORM\Column(name="account", type="string", length=30, nullable=true)
|
||||
* @Assert\Length(allowEmptyString=true, max="30", groups={"Registration", "UserCreate", "Profile"})
|
||||
*/
|
||||
private $accountNumber;
|
||||
/**
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
@@ -934,4 +944,14 @@ class User implements UserInterface, EquatableInterface, \Serializable
|
||||
|
||||
return $initial;
|
||||
}
|
||||
|
||||
public function getAccountNumber(): ?string
|
||||
{
|
||||
return $this->accountNumber;
|
||||
}
|
||||
|
||||
public function setAccountNumber(?string $accountNumber): void
|
||||
{
|
||||
$this->accountNumber = $accountNumber;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ class UserEditType extends AbstractType
|
||||
'label' => 'label.title',
|
||||
'required' => false,
|
||||
])
|
||||
->add('accountNumber', TextType::class, [
|
||||
'label' => 'label.account_number',
|
||||
'required' => false,
|
||||
])
|
||||
;
|
||||
|
||||
if ($this->configuration->isThemeAllowAvatarUrls()) {
|
||||
|
||||
38
src/Migrations/Version20210717211144.php
Normal file
38
src/Migrations/Version20210717211144.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* @version 1.15
|
||||
*/
|
||||
final class Version20210717211144 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$users = $schema->getTable('kimai2_users');
|
||||
$users->addColumn('account', 'string', ['length' => 30, 'notnull' => false, 'default' => null]);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$users = $schema->getTable('kimai2_users');
|
||||
$users->dropColumn('account');
|
||||
}
|
||||
}
|
||||
@@ -291,6 +291,7 @@ class UserRepository extends EntityRepository implements UserLoaderInterface
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->like('u.alias', ':searchTerm'),
|
||||
$qb->expr()->like('u.title', ':searchTerm'),
|
||||
$qb->expr()->like('u.accountNumber', ':searchTerm'),
|
||||
$qb->expr()->like('u.email', ':searchTerm'),
|
||||
$qb->expr()->like('u.username', ':searchTerm')
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user