mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
add a many-to-many relation to addresses
This commit is contained in:
@@ -72,4 +72,9 @@ Chill\PersonBundle\Entity\Person:
|
||||
inverseJoinColumns:
|
||||
language_id:
|
||||
referencedColumnName: id
|
||||
addresses:
|
||||
targetEntity: Chill\MainBundle\Entity\Address
|
||||
joinTable:
|
||||
name: chill_person_persons_to_addresses
|
||||
cascade: [persist, remove, merge, detach]
|
||||
lifecycleCallbacks: { }
|
||||
|
49
Resources/migrations/Version20160310161006.php
Normal file
49
Resources/migrations/Version20160310161006.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Application\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Add a many-to-many relationship between person and addresses
|
||||
*/
|
||||
class Version20160310161006 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('CREATE TABLE chill_person_persons_to_addresses ('
|
||||
. 'person_id INT NOT NULL, '
|
||||
. 'address_id INT NOT NULL, '
|
||||
. 'PRIMARY KEY(person_id, address_id))');
|
||||
$this->addSql('CREATE INDEX IDX_4655A196217BBB47 '
|
||||
. 'ON chill_person_persons_to_addresses (person_id)');
|
||||
$this->addSql('CREATE INDEX IDX_4655A196F5B7AF75 '
|
||||
. 'ON chill_person_persons_to_addresses (address_id)');
|
||||
$this->addSql('ALTER TABLE chill_person_persons_to_addresses '
|
||||
. 'ADD CONSTRAINT FK_4655A196217BBB47 '
|
||||
. 'FOREIGN KEY (person_id) '
|
||||
. 'REFERENCES Person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_persons_to_addresses '
|
||||
. 'ADD CONSTRAINT FK_4655A196F5B7AF75 '
|
||||
. 'FOREIGN KEY (address_id) '
|
||||
. 'REFERENCES chill_main_address (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('DROP TABLE chill_person_persons_to_addresses');
|
||||
|
||||
}
|
||||
}
|
@@ -70,6 +70,8 @@ Reset: 'Remise à zéro'
|
||||
'Person details': 'Détails de la personne'
|
||||
'Update details for %name%': 'Modifier détails de %name%'
|
||||
Accompanying period list: Périodes d'accompagnement
|
||||
Since %date%: Depuis le %date%
|
||||
No address given: Pas d'adresse renseignée
|
||||
|
||||
#timeline
|
||||
'An accompanying period is opened for %person% on %date%': Une période d'accompagnement a été ouverte le %date% pour %person%
|
||||
|
@@ -16,6 +16,8 @@
|
||||
#}
|
||||
{% extends "ChillPersonBundle::layout.html.twig" %}
|
||||
|
||||
{% import 'ChillMainBundle:Address:macro.html.twig' as address %}
|
||||
|
||||
{% set activeRouteKey = 'chill_person_view' %}
|
||||
|
||||
{#
|
||||
@@ -165,6 +167,19 @@ This view should receive those arguments:
|
||||
<figure class="person-details">
|
||||
<h2 class="chill-blue"><i class="fa fa-envelope-o"></i> {{ 'Contact information'|trans|upper }}</h2>
|
||||
|
||||
{%- if chill_person.fields.address == 'visible' -%}
|
||||
<dl>
|
||||
<dt>{{ 'Address'|trans }}</dt>
|
||||
<dd>
|
||||
{%- if person.lastAddress is not empty -%}
|
||||
{{ address._render(person.lastAddress) }}
|
||||
{%- else -%}
|
||||
<span class=".chill-no-data-statement">{{ 'No address given'|trans }}</span>
|
||||
{%- endif -%}
|
||||
</dd>
|
||||
</dl>
|
||||
{%- endif -%}
|
||||
|
||||
{%- if chill_person.fields.email == 'visible' -%}
|
||||
<dl>
|
||||
<dt>{{ 'Email'|trans }} :</dt>
|
||||
|
Reference in New Issue
Block a user