Compare commits

...

6 Commits

Author SHA1 Message Date
14e79c3b33 jsp 2024-11-28 14:10:25 +01:00
1184911dd0 3 2024-11-28 14:06:54 +01:00
941cb2d04f 2 2024-11-28 14:04:28 +01:00
e8baf76ad0 1 2024-11-28 14:01:51 +01:00
ee236ff74a templates v2 2024-11-21 16:52:37 +01:00
aeb96e4b68 templates 2024-11-21 16:31:49 +01:00
25 changed files with 704 additions and 147 deletions

34
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<<<<<<< HEAD
<data-source source="LOCAL" name="@172.20.96.1" uuid="76621fd2-6622-4f8e-a632-d7b7602e0afe">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://172.20.96.1:5432/</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="hegreconfort@127.0.0.1" uuid="a0219ca4-02a7-456a-bf02-9b3234ed346b">
<driver-ref>mariadb</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mariadb://127.0.0.1:3306/hegreconfort</jdbc-url>
=======
<data-source source="LOCAL" name="chauffageproj@172.20.96.1" uuid="6554e332-842b-41d7-a021-08782c7b72bb">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://172.20.96.1:5432/chauffageproj</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="chauffageproj@172.20.96.1 [2]" uuid="a446f2ca-1dfc-459a-97f5-eda71fd74aa2">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://172.20.96.1:5432/chauffageproj</jdbc-url>
>>>>>>> ee236ff74aaac1882a825817d5ce8f692d3bdd0f
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

View File

@ -5,8 +5,10 @@
</component>
<component name="ChangeListManager">
<list default="true" id="cf8b8ad0-a5ca-449a-93b5-e4441856adec" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/packages/security.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/config/packages/security.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Entity/User.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/UserRepository.php" beforeDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -15,12 +17,14 @@
</component>
<component name="ComposerSettings" synchronizationState="SYNCHRONIZE">
<pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
<execution />
<execution>
<executable path="composer" />
</execution>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="PhpWorkspaceProjectConfiguration" interpreter_name="C:\xampp\php\php.exe">
<component name="PhpWorkspaceProjectConfiguration" interpreter_name="/bin/php">
<include_path>
<path value="$PROJECT_DIR$/vendor/sebastian/exporter" />
<path value="$PROJECT_DIR$/vendor/sebastian/cli-parser" />
@ -163,19 +167,40 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "develop",
"last_opened_file_path": "C:/Users/serma/Desktop/HegreEtConfort",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
<<<<<<< HEAD
&quot;git-widget-placeholder&quot;: &quot;develop&quot;,
&quot;last_opened_file_path&quot;: &quot;E:/BTS/PhpStorm/centre_fitness&quot;,
=======
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;develop&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/ragueneaul@stsio.lan/Documents/DecoMaison_Lucas_Ragueneau&quot;,
>>>>>>> ee236ff74aaac1882a825817d5ce8f692d3bdd0f
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
<<<<<<< HEAD
&quot;php.add.doc.comment.for.fields.panel.add.php.doc.for.all.properties&quot;: &quot;true&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;inlay.hints&quot;,
=======
>>>>>>> ee236ff74aaac1882a825817d5ce8f692d3bdd0f
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
},
&quot;keyToStringList&quot;: {
&quot;DatabaseDriversLRU&quot;: [
<<<<<<< HEAD
&quot;postgresql&quot;,
&quot;mysql&quot;
=======
&quot;postgresql&quot;
>>>>>>> ee236ff74aaac1882a825817d5ce8f692d3bdd0f
]
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="E:\BTS\PhpStorm\HegreEtConfort\src\Entity" />
@ -190,8 +215,13 @@
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-js-predefined-d6986cc7102b-5c90d61e3bab-JavaScript-PS-242.23339.16" />
<option value="bundled-php-predefined-a98d8de5180a-90914f2295cb-com.jetbrains.php.sharedIndexes-PS-242.23339.16" />
<<<<<<< HEAD
<option value="bundled-js-predefined-d6986cc7102b-5c90d61e3bab-JavaScript-PS-242.23726.107" />
<option value="bundled-php-predefined-a98d8de5180a-90914f2295cb-com.jetbrains.php.sharedIndexes-PS-242.23726.107" />
=======
<option value="bundled-js-predefined-d6986cc7102b-e768b9ed790e-JavaScript-PS-243.21565.202" />
<option value="bundled-php-predefined-a98d8de5180a-5fbe0c30323e-com.jetbrains.php.sharedIndexes-PS-243.21565.202" />
>>>>>>> ee236ff74aaac1882a825817d5ce8f692d3bdd0f
</set>
</attachedChunks>
</component>
@ -206,6 +236,13 @@
<workItem from="1728656379062" duration="1875000" />
<workItem from="1728671983731" duration="846000" />
<workItem from="1729167245881" duration="2915000" />
<<<<<<< HEAD
<workItem from="1731589942576" duration="10448000" />
=======
<workItem from="1729175702600" duration="1829000" />
<workItem from="1731589591731" duration="13398000" />
<workItem from="1732193975936" duration="8317000" />
>>>>>>> ee236ff74aaac1882a825817d5ce8f692d3bdd0f
</task>
<servers />
</component>

View File

@ -4,14 +4,18 @@ security:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
users_in_memory: { memory: null }
# used to reload user from session & other features (e.g. switch_user)
app_user_provider:
entity:
class: App\Entity\User
property: email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
lazy: true
provider: users_in_memory
provider: app_user_provider
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#the-firewall

View File

@ -0,0 +1,43 @@
<?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 Version20241114151456 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 fault (id INT AUTO_INCREMENT NOT NULL, wording VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE intervention (id INT AUTO_INCREMENT NOT NULL, wording VARCHAR(255) NOT NULL, timestamp DATETIME NOT NULL, description VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, status VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE skill (id INT AUTO_INCREMENT NOT NULL, wording VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE stock (id INT AUTO_INCREMENT NOT NULL, wording VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, quantity 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, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, birth_date DATE NOT NULL, email VARCHAR(255) NOT NULL, phone VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE vehicle (id INT AUTO_INCREMENT NOT NULL, license_plate VARCHAR(255) NOT NULL, brand VARCHAR(255) NOT NULL, 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');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE fault');
$this->addSql('DROP TABLE intervention');
$this->addSql('DROP TABLE skill');
$this->addSql('DROP TABLE stock');
$this->addSql('DROP TABLE `user`');
$this->addSql('DROP TABLE vehicle');
$this->addSql('DROP TABLE messenger_messages');
}
}

View File

@ -0,0 +1,70 @@
<?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 Version20241121154657 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 SEQUENCE fault_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE intervention_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE skill_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE stock_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "user_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE vehicle_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE fault (id INT NOT NULL, wording VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE intervention (id INT NOT NULL, wording VARCHAR(255) NOT NULL, timestamp TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, description VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, status VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE skill (id INT NOT NULL, wording VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE stock (id INT NOT NULL, wording VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, quantity VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE "user" (id INT NOT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, birth_date DATE NOT NULL, email VARCHAR(255) NOT NULL, phone VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE vehicle (id INT NOT NULL, license_plate VARCHAR(255) NOT NULL, brand VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE messenger_messages (id BIGSERIAL NOT NULL, body TEXT NOT NULL, headers TEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, available_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, delivered_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)');
$this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)');
$this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)');
$this->addSql('COMMENT ON COLUMN messenger_messages.created_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN messenger_messages.available_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN messenger_messages.delivered_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('CREATE OR REPLACE FUNCTION notify_messenger_messages() RETURNS TRIGGER AS $$
BEGIN
PERFORM pg_notify(\'messenger_messages\', NEW.queue_name::text);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;');
$this->addSql('DROP TRIGGER IF EXISTS notify_trigger ON messenger_messages;');
$this->addSql('CREATE TRIGGER notify_trigger AFTER INSERT OR UPDATE ON messenger_messages FOR EACH ROW EXECUTE PROCEDURE notify_messenger_messages();');
}
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('DROP SEQUENCE fault_id_seq CASCADE');
$this->addSql('DROP SEQUENCE intervention_id_seq CASCADE');
$this->addSql('DROP SEQUENCE skill_id_seq CASCADE');
$this->addSql('DROP SEQUENCE stock_id_seq CASCADE');
$this->addSql('DROP SEQUENCE "user_id_seq" CASCADE');
$this->addSql('DROP SEQUENCE vehicle_id_seq CASCADE');
$this->addSql('DROP TABLE fault');
$this->addSql('DROP TABLE intervention');
$this->addSql('DROP TABLE skill');
$this->addSql('DROP TABLE stock');
$this->addSql('DROP TABLE "user"');
$this->addSql('DROP TABLE vehicle');
$this->addSql('DROP TABLE messenger_messages');
}
}

View File

@ -2,17 +2,49 @@
namespace App\Controller;
use App\Entity\Fault;
use App\Form\FaultType;
use App\Repository\FaultRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Routing\Annotation\Route;
class FaultController extends AbstractController
{
#[Route('/fault', name: 'app_fault')]
public function index(): Response
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly FaultRepository $faultRepository
)
{
return $this->render('fault/index.html.twig', [
'controller_name' => 'FaultController',
}
#[Route('/fault/add', name: 'fault_add')]
public function add(Request $request): Response
{
$fault = new Fault();
$form = $this->createForm(FaultType::class, $fault);
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid())
{
$this->entityManager->persist($fault);
$this->entityManager->flush();
return $this->redirectToRoute("app_fault_list");
}
return $this->render('fault/add.html.twig', [
'form' => $form,
]);
}
}
#[Route('/fault/list', name: 'fault_list')]
public function list(): Response
{
$fault = $this->faultRepository->findAll();
return $this->render('fault/list.html.twig', [
'fault' => $fault,
]);
}
}

View File

@ -2,17 +2,50 @@
namespace App\Controller;
use App\Entity\Intervention;
use App\Form\InterventionType;
use App\Repository\InterventionRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class InterventionController extends AbstractController
{
#[Route('/intervention', name: 'app_intervention')]
public function index(): Response
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly InterventionRepository $interventionRepository
)
{
return $this->render('intervention/index.html.twig', [
'controller_name' => 'InterventionController',
}
#[\Symfony\Component\Routing\Annotation\Route('/intervention/add', name: 'fault_add')]
public function add(Request $request): Response
{
$fault = new Intervention();
$form = $this->createForm(InterventionType::class, $fault);
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid())
{
$this->entityManager->persist($fault);
$this->entityManager->flush();
return $this->redirectToRoute("app_fault_list");
}
return $this->render('fault/add.html.twig', [
'form' => $form,
]);
}
}
#[Route('/fault/list', name: 'fault_list')]
public function list(): Response
{
$fault = $this->faultRepository->findAll();
return $this->render('fault/list.html.twig', [
'fault' => $fault,
]);
}
}

View File

@ -11,7 +11,7 @@ class SkillController extends AbstractController
#[Route('/skill', name: 'app_skill')]
public function index(): Response
{
return $this->render('skill/index.html.twig', [
return $this->render('skill/add.html.twig', [
'controller_name' => 'SkillController',
]);
}

View File

@ -2,17 +2,69 @@
namespace App\Controller;
use App\Entity\Stock;
use App\Form\StockType;
use App\Repository\StockRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Routing\Annotation\Route;
class StockController extends AbstractController
{
#[Route('/stock', name: 'app_stock')]
public function index(): Response
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly StockRepository $stockRepository
)
{
return $this->render('stock/index.html.twig', [
'controller_name' => 'StockController',
}
#[Route('/stock/add', name: 'stock_add')]
public function add(Request $request): Response
{
$stock = new Stock();
$form = $this->createForm(StockType::class, $stock);
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid())
{
$this->entityManager->persist($stock);
$this->entityManager->flush();
}
return $this->render('stock/add.html.twig', [
'form' => $form,
]);
}
}
#[Route('/stock/list', name: 'stock_list')]
public function list(): Response
{
$stocks = $this->stockRepository->findAll();
return $this->render('stock/list.html.twig', [
'stocks' => $stocks,
]);
}
#[Route('/stock/update/{id}', name: 'stock_update')]
public function update(int $id, Request $request): Response
{
$stock = $this->stockRepository->find($id);
$form = $this->createForm(StockType::class, $stock);
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid())
{
$this->entityManager->persist($stock);
$this->entityManager->flush();
}
return $this->render('stock/add.html.twig', [
'form' => $form,
]);
}
}

View File

@ -2,17 +2,77 @@
namespace App\Controller;
use App\Entity\User;
use App\Form\UserType;
use App\Repository\UserRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Routing\Annotation\Route;
class UserController extends AbstractController
{
#[Route('/user', name: 'app_user')]
public function index(): Response
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly UserRepository $userRepository
)
{
return $this->render('user/index.html.twig', [
'controller_name' => 'UserController',
}
#[Route('/user/add', name: 'user_add')]
public function add(Request $request): Response
{
$user = new User();
$form = $this->createForm(UserType::class, $user);
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid())
{
$this->entityManager->persist($user);
$this->entityManager->flush();
}
return $this->render('user/add.html.twig', [
'form' => $form,
]);
}
#[Route('/user/list', name: 'user_list')]
public function list(): Response
{
$users = $this->userRepository->findAll();
return $this->render('user/list.html.twig', [
'users' => $users,
]);
}
#[Route('/user/update/{id}', name: 'user_update')]
public function update(int $id, Request $request): Response
{
$user = $this->userRepository->find($id);
$form = $this->createForm(UserType::class, $user);
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid())
{
$this->entityManager->persist($user);
$this->entityManager->flush();
}
return $this->render('user/add.html.twig', [
'form' => $form,
]);
}
#[Route('/user/delete/{id}', name: '_delete')]
public function delete(int $id): Response
{
$user = $this->userRepository->find($id);
$this->entityManager->remove($user);
$this->entityManager->flush();
return $this->redirectToRoute('app_user_list');
}
}

View File

@ -11,7 +11,7 @@ class VehicleController extends AbstractController
#[Route('/vehicle', name: 'app_vehicle')]
public function index(): Response
{
return $this->render('vehicle/index.html.twig', [
return $this->render('vehicle/add.html.twig', [
'controller_name' => 'VehicleController',
]);
}

View File

@ -5,16 +5,21 @@ namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: '`user`')]
class User
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180)]
private ?string $email = null;
#[ORM\Column(length: 255)]
private ?string $FirstName = null;
@ -29,84 +34,154 @@ class User
#[ORM\Column(length: 255)]
private ?string $Phone = null;
/**
* @var list<string> The user roles
*/
#[ORM\Column]
private array $roles = [];
#[ORM\Column(length: 255)]
private ?string $Type = null;
/**
* @var string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
public function getId(): ?int
{
return $this->id;
}
public function getFirstName(): ?string
{
return $this->FirstName;
}
public function setFirstName(string $FirstName): static
{
$this->FirstName = $FirstName;
return $this;
}
public function getLastName(): ?string
{
return $this->LastName;
}
public function setLastName(string $LastName): static
{
$this->LastName = $LastName;
return $this;
}
/**
* @return \DateTimeInterface|null
*/
public function getBirthDate(): ?\DateTimeInterface
{
return $this->BirthDate;
}
public function setBirthDate(\DateTimeInterface $BirthDate): static
/**
* @param \DateTimeInterface|null $BirthDate
*/
public function setBirthDate(?\DateTimeInterface $BirthDate): void
{
$this->BirthDate = $BirthDate;
return $this;
}
public function getEmail(): ?string
/**
* @return string|null
*/
public function getLastName(): ?string
{
return $this->Email;
return $this->LastName;
}
public function setEmail(string $Email): static
/**
* @param string|null $LastName
*/
public function setLastName(?string $LastName): void
{
$this->Email = $Email;
return $this;
$this->LastName = $LastName;
}
/**
* @return string|null
*/
public function getFirstName(): ?string
{
return $this->FirstName;
}
/**
* @param string|null $FirstName
*/
public function setFirstName(?string $FirstName): void
{
$this->FirstName = $FirstName;
}
/**
* @return string|null
*/
public function getPhone(): ?string
{
return $this->Phone;
}
public function setPhone(string $Phone): static
/**
* @param string|null $Phone
*/
public function setPhone(?string $Phone): void
{
$this->Phone = $Phone;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): static
{
$this->email = $email;
return $this;
}
public function getType(): ?string
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return $this->Type;
return (string) $this->email;
}
public function setType(string $Type): static
/**
* @see UserInterface
*
* @return list<string>
*/
public function getRoles(): array
{
$this->Type = $Type;
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
/**
* @param list<string> $roles
*/
public function setRoles(array $roles): static
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): static
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function eraseCredentials(): void
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
}

28
src/Form/FaultType.php Normal file
View File

@ -0,0 +1,28 @@
<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class FaultType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('Wording', TextType::class)
->add('save', SubmitType::class)
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
// Configure your form options here
]);
}
}

33
src/Form/StockType.php Normal file
View File

@ -0,0 +1,33 @@
<?php
namespace App\Form;
use App\Entity\Stock;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class StockType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('Wording', TextType::class)
->add('Description', TextType::class)
->add('Quantity', IntegerType::class)
->add('save', SubmitType::class)
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Stock::class,
]);
}
}

35
src/Form/UserType.php Normal file
View File

@ -0,0 +1,35 @@
<?php
namespace App\Form;
use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class UserType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('FirstName', TextType::class)
->add('LastName', TextType::class)
->add('BirthDate', DateType::class)
->add('Email', EmailType::class)
->add('Phone', TextType::class)
->add('Type', TextType::class)
->add('Save', SubmitType::class)
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => User::class,
]);
}
}

View File

@ -5,17 +5,34 @@ namespace App\Repository;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
/**
* @extends ServiceEntityRepository<User>
*/
class UserRepository extends ServiceEntityRepository
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, User::class);
}
/**
* Used to upgrade (rehash) the user's password automatically over time.
*/
public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
{
if (!$user instanceof User) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $user::class));
}
$user->setPassword($newHashedPassword);
$this->getEntityManager()->persist($user);
$this->getEntityManager()->flush();
}
// /**
// * @return User[] Returns an array of User objects
// */

View File

@ -0,0 +1,10 @@
{% extends 'base.html.twig' %}
{% block title %}Ajouter une panne{% endblock %}
{% block body %}
<h1>Ajouter une panne</h1>
{{ form(form) }}
{% endblock %}

View File

@ -1,20 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Hello FaultController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code>E:/BTS/PhpStorm/HegreEtConfort/src/Controller/FaultController.php</code></li>
<li>Your template at <code>E:/BTS/PhpStorm/HegreEtConfort/templates/fault/index.html.twig</code></li>
</ul>
</div>
{% endblock %}

View File

@ -0,0 +1,9 @@
{% extends 'base.html.twig' %}
{% block title %}Hello UserController!{% endblock %}
{% block body %}
{% for user in users %}
{{ fault.Wording }}
{% endfor %}
{% endblock %}

View File

@ -0,0 +1,10 @@
{% extends 'base.html.twig' %}
{% block title %}Ajouter un utilisateur{% endblock %}
{% block body %}
<h1>Ajouter du stock</h1>
{{ form(form) }}
{% endblock %}

View File

@ -1,20 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Hello StockController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code>E:/BTS/PhpStorm/HegreEtConfort/src/Controller/StockController.php</code></li>
<li>Your template at <code>E:/BTS/PhpStorm/HegreEtConfort/templates/stock/index.html.twig</code></li>
</ul>
</div>
{% endblock %}

View File

@ -0,0 +1,11 @@
{% extends 'base.html.twig' %}
{% block title %}Hello StockController!{% endblock %}
{% block body %}
{% for stock in stocks %}
{{ stock.Wording }}
{{ stock.Description }}
{{ stock.Quantity }}
{% endfor %}
{% endblock %}

View File

@ -0,0 +1,10 @@
{# templates/user/add.html.twig #}
{% extends 'base.html.twig' %}
{% block title %}Ajouter un utilisateur{% endblock %}
{% block body %}
<h1>Ajouter un utilisateur</h1>
{{ form(form) }}
{% endblock %}

View File

@ -1,20 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Hello UserController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code>E:/BTS/PhpStorm/HegreEtConfort/src/Controller/UserController.php</code></li>
<li>Your template at <code>E:/BTS/PhpStorm/HegreEtConfort/templates/user/index.html.twig</code></li>
</ul>
</div>
{% endblock %}

View File

@ -0,0 +1,14 @@
{% extends 'base.html.twig' %}
{% block title %}Hello UserController!{% endblock %}
{% block body %}
{% for user in users %}
{{ user.FirstName }}
{{ user.LastName }}
{{ user.BirthDate|date("Y-m-d") }}
{{ user.Email }}
{{ user.Phone }}
{{ user.Type }}
{% endfor %}
{% endblock %}