<?php
 namespace Entity; class AriaChat extends \App\Entity\GeneralAbstract { protected $saveInsideTransaction = true; protected function setTableName(): void { global $DBTAriaChats; $this->tableName = $DBTAriaChats; } protected function getAttribute($var) { switch ($var) { case 'messagesList': { $chatsListObj = new \App\EntityList\AriaChats(); $chatsListObj->setFilter('ariaChatMessages.idChat', '=', $this->id); $chatsListObj->setColumns(['ariaChatMessages.*']); $chatsListObj->setOrderBy('ariaChatMessages.id', 'ASC'); $this->fields[$var] = $chatsListObj->exportRecords(); return $this->fields[$var]; } case 'user': { return \Entity\User::select($this->fields['idUser'], $this->selectForUpdate); } case 'addUser': { return \Entity\User::select($this->fields['idAddUser'], $this->selectForUpdate); } case 'updateUser': { return \Entity\User::select($this->fields['idUpdateUser'], $this->selectForUpdate); } default: { return parent::getAttribute($var); } } } protected function setAttribute($var, $value) { if ($this->operation!='insert' and $this->operation!='update') { throw new \Exception("You cannot use __set magic method on `{$this->operation}` operation in `".__CLASS__."` class."); } switch ($var) { case 'summary': case 'idUser': case 'reportSource': $this->fields[$var] = $value; break; default: { throw new \Exception("The field '$var' is not valid for the `".__METHOD__."` entity call."); } } } } 