/**
  * @param Person  $aPerson
  * @param Service $aService
  *
  * @return PersonService|null
  */
 public static function getByPersonAndServiceId(Person $aPerson, Service $aService)
 {
     $data = (new Query())->select('user_service.*')->from(self::$tableName . ' as user_service')->where(['user_service.person_id' => $aPerson->id(), 'user_service.service_id' => $aService->id()])->one();
     if (!$data) {
         return null;
     }
     /**
      * TODO: сделать чтобы присваивания делала факторка
      */
     $service = (new PersonServiceFactory())->createEmpty();
     $service->setId($data['id']);
     $service->setPersonId($data['person_id']);
     $service->setServiceId($data['service_id']);
     $service->setHourse($data['hours']);
     $service->setCost($data['cost']);
     return $service;
 }
Exemplo n.º 2
0
 public function equalsTo(Person $aPerson)
 {
     return $this->id() === $aPerson->id();
 }
Exemplo n.º 3
0
 public function getUserByPerson(Person $aPerson)
 {
     return User::find()->where(['person_id' => $aPerson->id()])->one();
 }