add fixtures

This commit is contained in:
Tykayn 2024-07-29 10:40:26 +02:00 committed by tykayn
parent 65413ef8ce
commit 4f7a471503
9 changed files with 74 additions and 51 deletions

View File

@ -24,9 +24,14 @@
<component name="ChangeListManager">
<list default="true" id="7b6ae3ea-b7de-4daa-94af-b6fb4f3c8b8e" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/migrations/Version20240716105848.php" beforeDir="false" afterPath="$PROJECT_DIR$/migrations/Version20240716105848.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controller/AccountController.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controller/AccountController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controller/Admin/DashboardController.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controller/Admin/DashboardController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controller/Admin/ExepenseConfigCrudController.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controller/Admin/ExpenseConfigCrudController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/DataFixtures/AppFixtures.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/DataFixtures/AppFixtures.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Entity/Product.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/Product.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Entity/ProductSold.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/ProductSold.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Entity/ExepenseConfig.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/ExpenseConfig.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Entity/User.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/User.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/ExepenseConfigRepository.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/ExepenseConfigRepository.php" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -252,7 +257,7 @@
&quot;keyToString&quot;: {
&quot;dart.analysis.tool.window.visible&quot;: &quot;false&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/poule/encrypted/stockage-syncable/www/development/html/caisse/templates/account&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/poule/encrypted/stockage-syncable/www/development/html/caisse-bliss-frontend&quot;,
&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;,
@ -312,7 +317,9 @@
<workItem from="1721124162582" duration="4590000" />
<workItem from="1721135270174" duration="484000" />
<workItem from="1721135995908" duration="8940000" />
<workItem from="1721246789470" duration="2162000" />
<workItem from="1721246789470" duration="2508000" />
<workItem from="1721288703800" duration="63000" />
<workItem from="1722241783852" duration="601000" />
</task>
<servers />
</component>

View File

@ -20,7 +20,7 @@ final class Version20240716105848 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE exepense_config (id INT AUTO_INCREMENT NOT NULL, owner_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, delay INT DEFAULT NULL, enabled TINYINT(1) DEFAULT NULL, amount INT NOT NULL, repeatitions INT DEFAULT NULL, INDEX IDX_4797F5B27E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE Expense_config (id INT AUTO_INCREMENT NOT NULL, owner_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, delay INT DEFAULT NULL, enabled TINYINT(1) DEFAULT NULL, amount INT NOT NULL, repeatitions INT DEFAULT NULL, INDEX IDX_4797F5B27E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE festival (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, fond_de_caisse_avant INT NOT NULL, fond_de_caisse_apres INT NOT NULL, chiffre_affaire INT NOT NULL, frais_inscription INT DEFAULT NULL, frais_hebergement INT DEFAULT NULL, frais_transport INT DEFAULT NULL, frais_repas INT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE product (id INT AUTO_INCREMENT NOT NULL, owner_id INT DEFAULT NULL, product_category_id INT DEFAULT NULL, stock_count INT NOT NULL, name VARCHAR(255) NOT NULL, image VARCHAR(255) DEFAULT NULL, INDEX IDX_D34A04AD7E3C61F9 (owner_id), INDEX IDX_D34A04ADBE6903FD (product_category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE product_category (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
@ -28,7 +28,7 @@ final class Version20240716105848 extends AbstractMigration
$this->addSql('CREATE TABLE product_sold (id INT AUTO_INCREMENT NOT NULL, owner_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, image VARCHAR(255) DEFAULT NULL, INDEX IDX_153AFF387E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE sell_record (id INT AUTO_INCREMENT NOT NULL, owner_id INT DEFAULT NULL, festival_id INT DEFAULT NULL, customer_gender VARCHAR(255) DEFAULT NULL, date DATE NOT NULL, amount INT NOT NULL, paid_by_customer INT DEFAULT NULL, INDEX IDX_F9F12A027E3C61F9 (owner_id), INDEX IDX_F9F12A028AEBAF57 (festival_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE serie_festival (id INT AUTO_INCREMENT NOT NULL, owner_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, date_creation DATE NOT NULL, INDEX IDX_4DFA58B17E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE exepense_config ADD CONSTRAINT FK_4797F5B27E3C61F9 FOREIGN KEY (owner_id) REFERENCES `user` (id)');
$this->addSql('ALTER TABLE Expense_config ADD CONSTRAINT FK_4797F5B27E3C61F9 FOREIGN KEY (owner_id) REFERENCES `user` (id)');
$this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04AD7E3C61F9 FOREIGN KEY (owner_id) REFERENCES `user` (id)');
$this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04ADBE6903FD FOREIGN KEY (product_category_id) REFERENCES product_category (id)');
$this->addSql('ALTER TABLE product_category_user ADD CONSTRAINT FK_DCE5B0FCBE6903FD FOREIGN KEY (product_category_id) REFERENCES product_category (id) ON DELETE CASCADE');
@ -46,7 +46,7 @@ final class Version20240716105848 extends AbstractMigration
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE `admin` (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, email VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('CREATE TABLE user_account (id INT AUTO_INCREMENT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('ALTER TABLE exepense_config DROP FOREIGN KEY FK_4797F5B27E3C61F9');
$this->addSql('ALTER TABLE Expense_config DROP FOREIGN KEY FK_4797F5B27E3C61F9');
$this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04AD7E3C61F9');
$this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04ADBE6903FD');
$this->addSql('ALTER TABLE product_category_user DROP FOREIGN KEY FK_DCE5B0FCBE6903FD');
@ -55,7 +55,7 @@ final class Version20240716105848 extends AbstractMigration
$this->addSql('ALTER TABLE sell_record DROP FOREIGN KEY FK_F9F12A027E3C61F9');
$this->addSql('ALTER TABLE sell_record DROP FOREIGN KEY FK_F9F12A028AEBAF57');
$this->addSql('ALTER TABLE serie_festival DROP FOREIGN KEY FK_4DFA58B17E3C61F9');
$this->addSql('DROP TABLE exepense_config');
$this->addSql('DROP TABLE Expense_config');
$this->addSql('DROP TABLE festival');
$this->addSql('DROP TABLE product');
$this->addSql('DROP TABLE product_category');

View File

@ -8,7 +8,7 @@ use Symfony\Component\Routing\Annotation\Route;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\User;
use App\Entity\ExepenseConfig;
use App\Entity\ExpenseConfig;
use App\Entity\SerieFestival;
use App\Entity\Festival;
use App\Entity\Product;

View File

@ -8,12 +8,12 @@ use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use ExepenseConfigCrudController;
use ExpenseConfigCrudController;
use UserCrudController;
use ProductCrudController;
use App\Entity\User;
use App\Entity\ExepenseConfig;
use App\Entity\ExpenseConfig;
use App\Entity\SerieFestival;
use App\Entity\Festival;
use App\Entity\Product;
@ -40,7 +40,7 @@ class DashboardController extends AbstractDashboardController
MenuItem::linkToDashboard('Dashboard', 'fa fa-home'),
MenuItem::section('Utilisatrices'),
MenuItem::linkToCrud('Gens', 'fa fa-user', User::class),
MenuItem::linkToCrud('Dépenses', 'fa fa-user', ExepenseConfig::class),
MenuItem::linkToCrud('Dépenses', 'fa fa-user', ExpenseConfig::class),
MenuItem::section('Biens'),
MenuItem::linkToCrud('Produits', 'fa fa-user', Product::class),
MenuItem::linkToCrud('Ventes', 'fa fa-user', ProductSold::class),

View File

@ -2,17 +2,17 @@
namespace App\Controller\Admin;
use App\Entity\ExepenseConfig;
use App\Entity\ExpenseConfig;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
class ExepenseConfigCrudController extends AbstractCrudController
class ExpenseConfigCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return ExepenseConfig::class;
return ExpenseConfig::class;
}
/*

View File

@ -4,39 +4,51 @@ namespace App\DataFixtures;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use App\Entity\ExpenseConfig as Expense;
use App\Entity\Product;
use App\Entity\User;
use App\Entity\ProductCategory;
class AppFixtures extends Fixture
{
public function load(ObjectManager $manager): void
{
$expense = new Exepense();
$expense = new Expense();
$expense->setName('courses au marché')
->setAmount(40);
$expense2 = new Exepense();
$expense2 = new Expense();
$expense2->setName('abonnement service compta')
->setAmount(60);
$expense3 = new Exepense();
$expense3 = new Expense();
$expense3->setName('plutonium récréatif')
->setAmount(15);
$product = new Product();
$product->setName('Un Livre d\'exemple');
$product
->setName('Un Livre d\'exemple')
->setPrice(15)
->setStockCount(12);
$product2 = new Product();
$product2->setName('Un poster')
->setPrice(12);
->setPrice(12)
->setStockCount(12);
$product3 = new Product();
$product3->setName('Chaudière à sel fondus')->setPrice(120000000);
$product3
->setName('Chaudière à sel fondus')
->setPrice(120000000)
->setStockCount(2);
$categ = new Category();
$categ = new ProductCategory();
$categ->setName('Livres');
$demo_user = new User();
$demo_user
->setEmail('demo@demo.com')
->setRoles('ROLE_ADMIN')
->setPassword('demo')
->setRoles(['ROLE_ADMIN'])
->addExpenseConfig($expense)
->addExpenseConfig($expense2)
->addExpenseConfig($expense3)
@ -50,7 +62,11 @@ class AppFixtures extends Fixture
$categ->addProduct($product);
$manager->persist($expense);
$manager->persist($expense2);
$manager->persist($expense3);
$manager->persist($product);
$manager->persist($product2);
$manager->persist($product3);
$manager->persist($categ);
$manager->persist($demo_user);

View File

@ -2,13 +2,13 @@
namespace App\Entity;
use App\Repository\ExepenseConfigRepository;
use App\Repository\ExpenseConfigRepository;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiResource;
#[ORM\Entity(repositoryClass: ExepenseConfigRepository::class)]
#[ORM\Entity(repositoryClass: ExpenseConfigRepository::class)]
#[ApiResource]
class ExepenseConfig
class ExpenseConfig
{
#[ORM\Id]
#[ORM\GeneratedValue]
@ -27,7 +27,7 @@ class ExepenseConfig
#[ORM\Column]
private ?int $amount = null;
#[ORM\ManyToOne(inversedBy: 'exepenseConfigs')]
#[ORM\ManyToOne(inversedBy: 'ExpenseConfigs')]
private ?User $owner = null;
#[ORM\Column(nullable: true)]

View File

@ -57,8 +57,8 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
#[ORM\OneToMany(targetEntity: ProductSold::class, mappedBy: 'owner')]
private Collection $product;
#[ORM\OneToMany(targetEntity: ExepenseConfig::class, mappedBy: 'owner')]
private Collection $exepenseConfigs;
#[ORM\OneToMany(targetEntity: ExpenseConfig::class, mappedBy: 'owner')]
private Collection $ExpenseConfigs;
#[ORM\OneToMany(targetEntity: SerieFestival::class, mappedBy: 'owner')]
private Collection $festivals;
@ -69,7 +69,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
$this->sellRecords = new ArrayCollection();
$this->productCategories = new ArrayCollection();
$this->product = new ArrayCollection();
$this->exepenseConfigs = new ArrayCollection();
$this->ExpenseConfigs = new ArrayCollection();
$this->festivals = new ArrayCollection();
}
@ -275,29 +275,29 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
}
/**
* @return Collection<int, ExepenseConfig>
* @return Collection<int, ExpenseConfig>
*/
public function getExepenseConfigs(): Collection
public function getExpenseConfigs(): Collection
{
return $this->exepenseConfigs;
return $this->ExpenseConfigs;
}
public function addExepenseConfig(ExepenseConfig $exepenseConfig): static
public function addExpenseConfig(ExpenseConfig $ExpenseConfig): static
{
if (!$this->exepenseConfigs->contains($exepenseConfig)) {
$this->exepenseConfigs->add($exepenseConfig);
$exepenseConfig->setOwner($this);
if (!$this->ExpenseConfigs->contains($ExpenseConfig)) {
$this->ExpenseConfigs->add($ExpenseConfig);
$ExpenseConfig->setOwner($this);
}
return $this;
}
public function removeExepenseConfig(ExepenseConfig $exepenseConfig): static
public function removeExpenseConfig(ExpenseConfig $ExpenseConfig): static
{
if ($this->exepenseConfigs->removeElement($exepenseConfig)) {
if ($this->ExpenseConfigs->removeElement($ExpenseConfig)) {
// set the owning side to null (unless already changed)
if ($exepenseConfig->getOwner() === $this) {
$exepenseConfig->setOwner(null);
if ($ExpenseConfig->getOwner() === $this) {
$ExpenseConfig->setOwner(null);
}
}

View File

@ -2,27 +2,27 @@
namespace App\Repository;
use App\Entity\ExepenseConfig;
use App\Entity\ExpenseConfig;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<ExepenseConfig>
* @extends ServiceEntityRepository<ExpenseConfig>
*
* @method ExepenseConfig|null find($id, $lockMode = null, $lockVersion = null)
* @method ExepenseConfig|null findOneBy(array $criteria, array $orderBy = null)
* @method ExepenseConfig[] findAll()
* @method ExepenseConfig[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
* @method ExpenseConfig|null find($id, $lockMode = null, $lockVersion = null)
* @method ExpenseConfig|null findOneBy(array $criteria, array $orderBy = null)
* @method ExpenseConfig[] findAll()
* @method ExpenseConfig[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ExepenseConfigRepository extends ServiceEntityRepository
class ExpenseConfigRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ExepenseConfig::class);
parent::__construct($registry, ExpenseConfig::class);
}
// /**
// * @return ExepenseConfig[] Returns an array of ExepenseConfig objects
// * @return ExpenseConfig[] Returns an array of ExpenseConfig objects
// */
// public function findByExampleField($value): array
// {
@ -36,7 +36,7 @@ class ExepenseConfigRepository extends ServiceEntityRepository
// ;
// }
// public function findOneBySomeField($value): ?ExepenseConfig
// public function findOneBySomeField($value): ?ExpenseConfig
// {
// return $this->createQueryBuilder('e')
// ->andWhere('e.exampleField = :val')