Lines
100.00%
24 / 24
Functions and Methods
100.00%
6 / 6
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| RequestRelation | 100.00% | 24 / 24 | 100.00% | 6 / 6 | 6 | 100.00% | 1 / 1 | |||
| getEntityMapping | 100.00% | 8 / 8 | 100.00% | 1 / 1 | 1 | |||||
| getReferenceMapping | 100.00% | 8 / 8 | 100.00% | 1 / 1 | 1 | |||||
| addConditionRequestId | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | |||||
| addConditionProviderId | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | |||||
| addConditionBookable | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | |||||
| addConditionSource | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace BO\Zmsbackend\RequestRelation\Repository; | |
| 4 | ||
| 5 | class RequestRelation extends \BO\Zmsbackend\Query\Base implements \BO\Zmsbackend\Query\MappingInterface | |
| 6 | { | |
| 7 | const string TABLE = 'request_provider'; | |
| 8 | ||
| 9 | const string ALIAS = 'request_provider'; | |
| 10 | ||
| 11 | /** | |
| 12 | * @return string[] | |
| 13 | * | |
| 14 | */ | |
| 15 | #[\Override] | |
| 16 | public function getEntityMapping() | |
| 17 | { | |
| 18 | return [ | |
| 19 | 'request__id' => self::TABLE . '.request__id', | |
| 20 | 'provider__id' => self::TABLE . '.provider__id', | |
| 21 | 'source' => self::TABLE . '.source', | |
| 22 | 'slots' => self::TABLE . '.slots', | |
| 23 | 'public' => self::TABLE . '.public_visibility', | |
| 24 | 'maxQuantity' => self::TABLE . '.max_quantity' | |
| 25 | ]; | |
| 26 | } | |
| 27 | ||
| 28 | /** | |
| 29 | * @return \BO\Zmsbackend\Query\Builder\Expression[] | |
| 30 | * | |
| 31 | */ | |
| 32 | #[\Override] | |
| 33 | public function getReferenceMapping() | |
| 34 | { | |
| 35 | return [ | |
| 36 | 'request__$ref' => self::expression( | |
| 37 | 'CONCAT("/request/", `' . self::TABLE . '`.`source`, "/", `' . self::TABLE . '`.`request__id`, "/")' | |
| 38 | ), | |
| 39 | 'provider__$ref' => self::expression( | |
| 40 | 'CONCAT("/provider/", `' . self::TABLE . '`.`source`, "/", `' . self::TABLE . '`.`provider__id`, "/")' | |
| 41 | ) | |
| 42 | ]; | |
| 43 | } | |
| 44 | ||
| 45 | public function addConditionRequestId($requestId): static | |
| 46 | { | |
| 47 | $this->query->where(self::TABLE . '.request__id', '=', $requestId); | |
| 48 | return $this; | |
| 49 | } | |
| 50 | ||
| 51 | public function addConditionProviderId($providerId): static | |
| 52 | { | |
| 53 | $this->query->where(self::TABLE . '.provider__id', '=', $providerId); | |
| 54 | return $this; | |
| 55 | } | |
| 56 | ||
| 57 | public function addConditionBookable(): static | |
| 58 | { | |
| 59 | $this->query->where(self::TABLE . '.bookable', '=', 1); | |
| 60 | return $this; | |
| 61 | } | |
| 62 | ||
| 63 | public function addConditionSource($sourceName): static | |
| 64 | { | |
| 65 | $this->query->where(self::TABLE . '.source', '=', $sourceName); | |
| 66 | return $this; | |
| 67 | } | |
| 68 | } |