Add MessageFeedback Entity

pull/2944/head
Julio Montoya 6 years ago
parent 62499bd8af
commit de7e550830
  1. 191
      src/CoreBundle/Entity/MessageFeedback.php
  2. 20
      src/CoreBundle/Migrations/Schema/V200/Version20.php

@ -0,0 +1,191 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;
use Chamilo\UserBundle\Entity\User;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Index;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* Class MessageFeedback.
*
* @ORM\Table(
* name="message_feedback",
* indexes={
* @Index(name="idx_message_feedback_uid_mid", columns={"message_id", "user_id"})
* }
* )
* @ORM\Entity()
*/
class MessageFeedback
{
/**
* @var int
*
* @ORM\Column(name="id", type="bigint")
* @ORM\Id()
* @ORM\GeneratedValue()
*/
protected $id;
/**
* @var Message
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Message", inversedBy="likes")
* @ORM\JoinColumn(name="message_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/
protected $message;
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/
protected $user;
/**
* @var bool
*
* @ORM\Column(name="liked", type="boolean", options={"default": false})
*/
protected $liked;
/**
* @var bool
*
* @ORM\Column(name="disliked", type="boolean", options={"default": false})
*/
protected $disliked;
/**
* @var \DateTime
*
* @Gedmo\Timestampable(on="update")
*
* @ORM\Column(name="updated_at", type="datetime", nullable=false)
*/
protected $updatedAt;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*
* @return MessageFeedback
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* @return Message
*/
public function getMessage()
{
return $this->message;
}
/**
* @param Message $message
*
* @return MessageFeedback
*/
public function setMessage(Message $message)
{
$this->message = $message;
return $this;
}
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
/**
* @param User $user
*
* @return MessageFeedback
*/
public function setUser(User $user)
{
$this->user = $user;
return $this;
}
/**
* @return bool
*/
public function isLiked()
{
return $this->liked;
}
/**
* @param bool $liked
*
* @return MessageFeedback
*/
public function setLiked($liked)
{
$this->liked = $liked;
return $this;
}
/**
* @return bool
*/
public function isDisliked()
{
return $this->disliked;
}
/**
* @param bool $disliked
*
* @return MessageFeedback
*/
public function setDisliked($disliked)
{
$this->disliked = $disliked;
return $this;
}
/**
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* @param \DateTime $updatedAt
*
* @return MessageFeedback
*/
public function setUpdatedAt(\DateTime $updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
}

@ -203,10 +203,10 @@ class Version20 extends AbstractMigrationChamilo
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'lp', 'LearningPath')");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'exercise_and_lp', 'ExerciseAndLearningPath')");
$cSurvey = $schema->getTable('c_survey');
$survey = $schema->getTable('c_survey');
if (!$cSurvey->hasColumn('is_mandatory')) {
$cSurvey->addColumn('is_mandatory', Type::BOOLEAN)->setDefault(false);
if (!$survey->hasColumn('is_mandatory')) {
$survey->addColumn('is_mandatory', Type::BOOLEAN)->setDefault(false);
}
$this->addSql('ALTER TABLE c_student_publication ADD filesize INT DEFAULT NULL');
@ -216,6 +216,20 @@ class Version20 extends AbstractMigrationChamilo
$this->addSql('ALTER TABLE c_survey_invitation CHANGE reminder_date reminder_date DATETIME DEFAULT NULL');
$this->addSql('UPDATE c_survey_invitation SET reminder_date = NULL WHERE CAST(reminder_date AS CHAR(20)) = "0000-00-00 00:00:00"');
$table = $schema->hasTable('message_feedback');
if ($table === false) {
$this->addSql(
'CREATE TABLE message_feedback (id BIGINT AUTO_INCREMENT NOT NULL, message_id BIGINT NOT NULL, user_id INT NOT NULL, liked TINYINT(1) DEFAULT 0 NOT NULL, disliked TINYINT(1) DEFAULT 0 NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_DB0F8049537A1329 (message_id), INDEX IDX_DB0F8049A76ED395 (user_id), INDEX idx_message_feedback_uid_mid (message_id, user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC;'
);
$this->addSql(
'ALTER TABLE message_feedback ADD CONSTRAINT FK_DB0F8049537A1329 FOREIGN KEY (message_id) REFERENCES message (id) ON DELETE CASCADE'
);
$this->addSql(
'ALTER TABLE message_feedback ADD CONSTRAINT FK_DB0F8049A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE;'
);
}
/*$table = $schema->getTable('course_rel_class');
if (!$table->hasColumn('c_id')) {
$this->addSql("ALTER TABLE course_rel_class ADD c_id int NOT NULL");

Loading…
Cancel
Save