/** * Возвращает список направления обучения для пересохранения (дилера, студента, и тд.) * @param $brandsMethodist * @param $entityBrands * @param array $formBrands * @return array */ public static function getCalculationResult($brandsMethodist, $entityBrands, array $formBrands) { $brandsAll = \Brands::find(); $data = array(); foreach ($brandsAll as $brand) { $issetInMethodist = EntityService::inEntityRecursive($brandsMethodist, $brand->id, "activity_id"); $issetInEntity = EntityService::inEntityRecursive($entityBrands, $brand->id, "activity_id"); // если бренд отсутствует у методиста и присудствует у entity if (!$issetInMethodist and $issetInEntity) { $data[] = $brand; } } if ($formBrands === array()) { return $data; } $brandsByForm = \Brands::find("id IN (" . implode(",", $formBrands) . ")"); foreach ($brandsByForm as $brandByForm) { $data[] = $brandByForm; } return $data; }
<?php /** * @author dipompeodaniele@gmail.com, n.sacco.dev@gmail.com * */ require_once realpath(dirname(__FILE__)) . '/core.php'; class EntityService extends Entity { public function __construct($database, $name) { parent::__construct($database, $name); $this->setPresentation("name"); $this->addField("name", VARCHAR, 100); $this->addField("script", VARCHAR, 100); $this->addField("entry", VARCHAR, 100); $this->addField("visible", VARCHAR, 1); $this->addField("des", TEXT); $this->addField("position", POSITION); } } $servicesEntity = new EntityService($database, "sys_service"); $servicesEntity->addReference($servicecategoryEntity, "servicecategory"); $servicesEntity->addReference($entitiesEntity, "entities"); $servicesEntity->addReference($groupsEntity, "superuser_group");