add fields

This commit is contained in:
Simon Vieille 2022-05-17 22:19:51 +02:00
parent 4a3988f5b6
commit e2b627a1d5
Signed by: deblan
GPG key ID: 579388D585F70417
9 changed files with 137 additions and 4 deletions

1
.gitignore vendored
View file

@ -29,3 +29,4 @@ yarn-error.log
/public/media/
/migrations/*
!/migrations/.gitkeep
/.build

View file

@ -4,6 +4,8 @@ namespace App\Entity;
use App\Core\Entity\EntityInterface;
use App\Repository\ConferenceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
@ -54,6 +56,21 @@ class Conference implements EntityInterface
*/
protected $date;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $price;
/**
* @ORM\ManyToMany(targetEntity=Speaker::class, inversedBy="conferences")
*/
private $speakers;
public function __construct()
{
$this->speakers = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
@ -142,4 +159,40 @@ class Conference implements EntityInterface
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(?float $price): self
{
$this->price = $price;
return $this;
}
/**
* @return Collection<int, Speaker>
*/
public function getSpeakers(): Collection
{
return $this->speakers;
}
public function addSpeaker(Speaker $speaker): self
{
if (!$this->speakers->contains($speaker)) {
$this->speakers[] = $speaker;
}
return $this;
}
public function removeSpeaker(Speaker $speaker): self
{
$this->speakers->removeElement($speaker);
return $this;
}
}

View file

@ -55,6 +55,11 @@ class Project implements EntityInterface
*/
private $events;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $price;
public function __construct()
{
$this->establishments = new ArrayCollection();
@ -206,4 +211,16 @@ class Project implements EntityInterface
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(?float $price): self
{
$this->price = $price;
return $this;
}
}

View file

@ -61,10 +61,16 @@ class Speaker implements EntityInterface, EncryptedEntityInterface
*/
private $color;
/**
* @ORM\ManyToMany(targetEntity=Conference::class, mappedBy="speakers")
*/
private $conferences;
public function __construct()
{
$this->interventions = new ArrayCollection();
$this->events = new ArrayCollection();
$this->conferences = new ArrayCollection();
}
public function __toString()
@ -209,4 +215,31 @@ class Speaker implements EntityInterface, EncryptedEntityInterface
return $this;
}
/**
* @return Collection<int, Conference>
*/
public function getConferences(): Collection
{
return $this->conferences;
}
public function addConference(Conference $conference): self
{
if (!$this->conferences->contains($conference)) {
$this->conferences[] = $conference;
$conference->addSpeaker($this);
}
return $this;
}
public function removeConference(Conference $conference): self
{
if ($this->conferences->removeElement($conference)) {
$conference->removeSpeaker($this);
}
return $this;
}
}

View file

@ -6,6 +6,7 @@ use App\Entity\Conference;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
class ConferenceType extends AbstractType
{
@ -14,10 +15,21 @@ class ConferenceType extends AbstractType
$builder
->add('label')
->add('themeType')
->add('price', NumberType::class, [
'attr' => [
'step' => 0.01,
],
'scale' => 2,
'required' => false,
'html5' => true,
])
->add('date', null, [
'html5' => true,
'widget' => 'single_text',
])
->add('speakers', null, [
'expanded' => true,
])
->add('persons')
->add('content', null, [
'attr' => ['rows' => 7],

View file

@ -8,6 +8,7 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use App\Core\Form\Type\CollectionType;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
class ProjectType extends AbstractType
{
@ -26,8 +27,23 @@ class ProjectType extends AbstractType
->addOrderBy('e.name', 'ASC');
},
])
->add('description')
->add('client')
->add('price', NumberType::class, [
'row_attr' => [
'class' => 'col-md-3',
],
'attr' => [
'step' => 0.01,
],
'scale' => 2,
'required' => false,
'html5' => true,
])
->add('description', null, [
'attr' => ['rows' => 7],
])
->add('client', null, [
'attr' => ['rows' => 7],
])
->add('files',
CollectionType::class,
[

View file

@ -1,6 +1,6 @@
<div class="row">
<div class="col-md-3 order-1 pr-md-3">
{% for item in ['themeType', 'date', 'persons'] %}
{% for item in ['themeType', 'date', 'persons', 'price', 'speakers'] %}
{% include(configuration.view('form_widget', '@Core/admin/crud/_form_widget.html.twig')) with {form: form[item]} %}
{% endfor %}
</div>

View file

@ -1,6 +1,6 @@
<div class="row">
<div class="col-md-3">
{% for item in ['date', 'establishmentGroups', 'activityReference', 'groups', 'levels', 'speakers'] %}
{% for item in ['date', 'establishmentGroups', 'activityReference', 'groups', 'levels', 'speakers', 'price'] %}
{% include(configuration.view('form_widget', '@Core/admin/crud/_form_widget.html.twig')) with {form: form[item]} %}
{% endfor %}
</div>

View file

@ -44,3 +44,4 @@
"Distance": "Distance (sans retour)"
"Is round trip": "Aller-retour"
"Amount": "Montant (TTC)"
"Price": "Prix"