-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from WildCodeSchool-2023-09/S6_US302_admin_add…
…_prize S6 us302 admin add prize
- Loading branch information
Showing
16 changed files
with
228 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,6 @@ | |
} | ||
|
||
|
||
|
||
// | ||
|
||
@media screen and (min-width: $desktopWidth) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,7 +108,6 @@ | |
|
||
.guest-message { | ||
margin-top: 5px; | ||
color: red; | ||
font-size: 1rem; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?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 Version20240204135041 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('CREATE TABLE category (id INT AUTO_INCREMENT NOT NULL, label VARCHAR(100) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('CREATE TABLE game (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(100) NOT NULL, poster VARCHAR(255) DEFAULT NULL, update_at DATETIME DEFAULT NULL, description LONGTEXT NOT NULL, is_virtual TINYINT(1) NOT NULL, is_visible TINYINT(1) DEFAULT NULL, slug VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('CREATE TABLE game_category (game_id INT NOT NULL, category_id INT NOT NULL, INDEX IDX_AD08E6E7E48FD905 (game_id), INDEX IDX_AD08E6E712469DE2 (category_id), PRIMARY KEY(game_id, category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('CREATE TABLE game_played (id INT AUTO_INCREMENT NOT NULL, game_id INT NOT NULL, player_id INT NOT NULL, score INT NOT NULL, date DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', duration INT NOT NULL, uuid VARCHAR(255) NOT NULL, INDEX IDX_11F862FCE48FD905 (game_id), INDEX IDX_11F862FC99E6F5DF (player_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('CREATE TABLE picture (id INT AUTO_INCREMENT NOT NULL, game_id INT NOT NULL, file_name VARCHAR(255) NOT NULL, INDEX IDX_16DB4F89E48FD905 (game_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('CREATE TABLE prize (id INT AUTO_INCREMENT NOT NULL, label VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, poster VARCHAR(255) DEFAULT NULL, update_at DATETIME DEFAULT NULL, value INT NOT NULL, quantity INT NOT NULL, slug VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, firstname VARCHAR(100) NOT NULL, lastname VARCHAR(100) NOT NULL, token INT NOT NULL, phonenumber VARCHAR(16) DEFAULT NULL, adress VARCHAR(100) DEFAULT NULL, city VARCHAR(100) DEFAULT NULL, zipcode VARCHAR(5) DEFAULT NULL, email VARCHAR(40) NOT NULL, experience INT NOT NULL, level INT NOT NULL, UNIQUE INDEX UNIQ_8D93D649F85E0677 (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('CREATE TABLE messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', available_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', delivered_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_75EA56E0FB7336F0 (queue_name), INDEX IDX_75EA56E0E3BD61CE (available_at), INDEX IDX_75EA56E016BA31DB (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('ALTER TABLE game_category ADD CONSTRAINT FK_AD08E6E7E48FD905 FOREIGN KEY (game_id) REFERENCES game (id) ON DELETE CASCADE'); | ||
$this->addSql('ALTER TABLE game_category ADD CONSTRAINT FK_AD08E6E712469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE CASCADE'); | ||
$this->addSql('ALTER TABLE game_played ADD CONSTRAINT FK_11F862FCE48FD905 FOREIGN KEY (game_id) REFERENCES game (id)'); | ||
$this->addSql('ALTER TABLE game_played ADD CONSTRAINT FK_11F862FC99E6F5DF FOREIGN KEY (player_id) REFERENCES user (id)'); | ||
$this->addSql('ALTER TABLE picture ADD CONSTRAINT FK_16DB4F89E48FD905 FOREIGN KEY (game_id) REFERENCES game (id)'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE game_category DROP FOREIGN KEY FK_AD08E6E7E48FD905'); | ||
$this->addSql('ALTER TABLE game_category DROP FOREIGN KEY FK_AD08E6E712469DE2'); | ||
$this->addSql('ALTER TABLE game_played DROP FOREIGN KEY FK_11F862FCE48FD905'); | ||
$this->addSql('ALTER TABLE game_played DROP FOREIGN KEY FK_11F862FC99E6F5DF'); | ||
$this->addSql('ALTER TABLE picture DROP FOREIGN KEY FK_16DB4F89E48FD905'); | ||
$this->addSql('DROP TABLE category'); | ||
$this->addSql('DROP TABLE game'); | ||
$this->addSql('DROP TABLE game_category'); | ||
$this->addSql('DROP TABLE game_played'); | ||
$this->addSql('DROP TABLE picture'); | ||
$this->addSql('DROP TABLE prize'); | ||
$this->addSql('DROP TABLE user'); | ||
$this->addSql('DROP TABLE messenger_messages'); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace App\Form; | ||
|
||
use App\Entity\Prize; | ||
use App\Entity\User; | ||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | ||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\TextareaType; | ||
use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
use Symfony\Component\Validator\Constraints\Length; | ||
use Symfony\Component\Validator\Constraints\NotBlank; | ||
use Vich\UploaderBundle\Form\Type\VichFileType; | ||
|
||
class PrizeType extends AbstractType | ||
{ | ||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$builder | ||
->add('label', TextType::class, [ | ||
'constraints' => [ | ||
new NotBlank([ | ||
'message' => 'Please enter the title', | ||
]), | ||
new Length([ | ||
'min' => 2, | ||
'max' => 100, | ||
]), | ||
], | ||
]) | ||
->add('description', TextareaType::class, [ | ||
'constraints' => [ | ||
new NotBlank([ | ||
'message' => 'Please enter the description', | ||
]), | ||
new Length([ | ||
'min' => 2, | ||
'max' => 200, | ||
'minMessage' => 'Your description should be at least {{ limit }} characters', | ||
'maxMessage' => 'Your description should not be longer than {{ limit }} characters', | ||
]), | ||
], | ||
]) | ||
->add('posterFile', VichFileType::class, [ | ||
'required' => true, | ||
]) | ||
->add('value', TextType::class, [ | ||
'attr' => [ | ||
'required' => true, | ||
] | ||
]) | ||
->add('quantity', TextType::class, [ | ||
'attr' => [ | ||
'required' => false, | ||
] | ||
]) | ||
; | ||
} | ||
|
||
public function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver->setDefaults([ | ||
'data_class' => Prize::class, | ||
]); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<form method="post" action="{{ path('prize_delete', {'slug': prize.slug}) }}" onsubmit="return confirm('Are you sure you want to delete this prize?');"> | ||
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ prize.id) }}"> | ||
<input type="image" src="{{ asset('build/images/icons/deleteprize.png') }}" alt="Delete"> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div id="game-add"> | ||
{{ form_start(prizeForm) }} | ||
<div class="game-input"> | ||
{{ form_errors(prizeForm) }} | ||
|
||
{{ form_row(prizeForm.label) }} | ||
{{ form_row(prizeForm.description, {'attr': {'class': 'description'}}) }} | ||
{{ form_row(prizeForm.posterFile) }} | ||
{{ form_row(prizeForm.value) }} | ||
{{ form_row(prizeForm.quantity) }} | ||
|
||
<div> | ||
<button type="submit" id="add-edit-game">Save Prize</button> | ||
</div> | ||
</div> | ||
{{ form_end(prizeForm) }} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% extends 'base.html.twig' %} | ||
|
||
{% block content %} | ||
<div class="card full-size"> | ||
<div class="content"> | ||
<h2>Edit Game</h2> | ||
{{ include('prize/_form.html.twig') }} | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.