public static function getByPerson(Person $aPerson) { if (!$aPerson->studioId()) { return null; } $data = (new Query())->select('studio.*')->from(self::$studioTableName . ' as studio')->where(['id' => $aPerson->studioId()])->one(); $studio = self::getFactory()->create($data['address'], $data['name'], $data['phone']); $studio->setId($data['id']); return $studio; }
public static function withoutStudio(Person $aPerson) { return (int) $aPerson->studioId() === self::EMPTY_STUDIO_ID; }
private function update(Person $aPerson) { $db = $this->db(); $db->createCommand()->update(self::$tableName, ['studio_id' => $aPerson->studioId(), 'first_name' => $aPerson->firstName(), 'last_name' => $aPerson->lastName(), 'sex' => $aPerson->sex() ? $aPerson->sex()->type() : null, 'date_birth' => $aPerson->dateBirth() ? $aPerson->dateBirth()->format('Y-m-d H:i:s') : null, 'mob_phone' => $aPerson->mobPhone(), 'phone' => $aPerson->phone(), 'address' => $aPerson->address(), 'email' => $aPerson->email(), 'about' => $aPerson->about()], ['id' => $aPerson->id()])->execute(); }