add fixtures, add price to Product
This commit is contained in:
parent
5395dd2fb6
commit
65413ef8ce
|
@ -24,14 +24,9 @@
|
|||
<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$/src/Entity/ExepenseConfig.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/ExepenseConfig.php" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Entity/Festival.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/Festival.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/ProductCategory.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/ProductCategory.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/SellRecord.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/SellRecord.php" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Entity/SerieFestival.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/SerieFestival.php" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Entity/User.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/User.php" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -317,7 +312,7 @@
|
|||
<workItem from="1721124162582" duration="4590000" />
|
||||
<workItem from="1721135270174" duration="484000" />
|
||||
<workItem from="1721135995908" duration="8940000" />
|
||||
<workItem from="1721246789470" duration="170000" />
|
||||
<workItem from="1721246789470" duration="2162000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?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 Version20240717204253 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 product ADD price INT NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE product DROP price');
|
||||
}
|
||||
}
|
|
@ -13,10 +13,22 @@ class AppFixtures extends Fixture
|
|||
$expense = new Exepense();
|
||||
$expense->setName('courses au marché')
|
||||
->setAmount(40);
|
||||
$expense2 = new Exepense();
|
||||
$expense2->setName('abonnement service compta')
|
||||
->setAmount(60);
|
||||
$expense3 = new Exepense();
|
||||
$expense3->setName('plutonium récréatif')
|
||||
->setAmount(15);
|
||||
|
||||
$product = new Product();
|
||||
$product->setName('Un Livre d\'exemple');
|
||||
|
||||
$product2 = new Product();
|
||||
$product2->setName('Un poster')
|
||||
->setPrice(12);
|
||||
$product3 = new Product();
|
||||
$product3->setName('Chaudière à sel fondus')->setPrice(120000000);
|
||||
|
||||
$categ = new Category();
|
||||
$categ->setName('Livres');
|
||||
|
||||
|
@ -26,11 +38,12 @@ class AppFixtures extends Fixture
|
|||
->setEmail('demo@demo.com')
|
||||
->setRoles('ROLE_ADMIN')
|
||||
->addExpenseConfig($expense)
|
||||
->addProduct($product);
|
||||
|
||||
$product
|
||||
->setCategory($categ)
|
||||
->setOwner($demo_user);
|
||||
->addExpenseConfig($expense2)
|
||||
->addExpenseConfig($expense3)
|
||||
->addProduct($product)
|
||||
->addProduct($product2)
|
||||
->addProduct($product3)
|
||||
;
|
||||
|
||||
$expense->setOwner($demo_user);
|
||||
|
||||
|
|
|
@ -30,6 +30,9 @@ class Product
|
|||
#[ORM\ManyToOne(inversedBy: 'products')]
|
||||
private ?ProductCategory $productCategory = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $price = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
|
@ -94,4 +97,16 @@ class Product
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPrice(): ?int
|
||||
{
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
public function setPrice(int $price): static
|
||||
{
|
||||
$this->price = $price;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@ use ApiPlatform\Metadata\ApiResource;
|
|||
|
||||
#[ORM\Entity(repositoryClass: ProductSoldRepository::class)]
|
||||
#[ApiResource]
|
||||
/***
|
||||
* Un ensemble de produits vendus
|
||||
**/
|
||||
class ProductSold
|
||||
{
|
||||
#[ORM\Id]
|
||||
|
|
Loading…
Reference in New Issue