use username
This commit is contained in:
parent
5a32d90adc
commit
d74c283830
6 changed files with 58 additions and 8 deletions
34
migrations/Version20210422155430.php
Normal file
34
migrations/Version20210422155430.php
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20210422155430 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription() : string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema) : void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE "user" ADD username VARCHAR(255) NOT NULL DEFAULT \'\'');
|
||||||
|
$this->addSql('ALTER TABLE "user" ALTER is_verified DROP DEFAULT');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema) : void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SCHEMA public');
|
||||||
|
$this->addSql('ALTER TABLE "user" DROP username');
|
||||||
|
$this->addSql('ALTER TABLE "user" ALTER is_verified SET DEFAULT \'true\'');
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,4 +15,12 @@ class AppController extends AbstractController
|
||||||
'controller_name' => 'AppController',
|
'controller_name' => 'AppController',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/user', name: 'user_page')]
|
||||||
|
public function user(): Response
|
||||||
|
{
|
||||||
|
return $this->render('app/index.html.twig', [
|
||||||
|
'user' => $this->getUser(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,11 @@ class User implements UserInterface
|
||||||
*/
|
*/
|
||||||
private $isVerified = false;
|
private $isVerified = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=255)
|
||||||
|
*/
|
||||||
|
private $username;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
@ -66,7 +71,7 @@ class User implements UserInterface
|
||||||
*/
|
*/
|
||||||
public function getUsername(): string
|
public function getUsername(): string
|
||||||
{
|
{
|
||||||
return (string) $this->email;
|
return (string) $this->username;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,4 +139,11 @@ class User implements UserInterface
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setUsername(string $username): self
|
||||||
|
{
|
||||||
|
$this->username = $username;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ class RegistrationFormType extends AbstractType
|
||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('email')
|
->add('email')
|
||||||
|
->add('username')
|
||||||
->add('agreeTerms', CheckboxType::class, [
|
->add('agreeTerms', CheckboxType::class, [
|
||||||
'mapped' => false,
|
'mapped' => false,
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
|
|
|
@ -9,12 +9,6 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="example-wrapper">
|
<div class="example-wrapper">
|
||||||
<h1>Hello {{ controller_name }}! ✅</h1>
|
<h1>Hello {{ user.username }}!</h1>
|
||||||
|
|
||||||
This friendly message is coming from:
|
|
||||||
<ul>
|
|
||||||
<li>Your controller at <code><a href="{{ '/home/thisfro/repos/plant-exchange/src/Controller/AppController.php'|file_link(0) }}">src/Controller/AppController.php</a></code></li>
|
|
||||||
<li>Your template at <code><a href="{{ '/home/thisfro/repos/plant-exchange/templates/app/index.html.twig'|file_link(0) }}">templates/app/index.html.twig</a></code></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
{{ form_start(registrationForm) }}
|
{{ form_start(registrationForm) }}
|
||||||
{{ form_row(registrationForm.email) }}
|
{{ form_row(registrationForm.email) }}
|
||||||
|
{{ form_row(registrationForm.username) }}
|
||||||
{{ form_row(registrationForm.plainPassword, {
|
{{ form_row(registrationForm.plainPassword, {
|
||||||
label: 'Password'
|
label: 'Password'
|
||||||
}) }}
|
}) }}
|
||||||
|
|
Reference in a new issue