hasOne(Partner::class, ['id' => 'partner_id']); } public static function eventTypes($type = null) { $types = [ 'simple' => 'Обикновено събитие', 'online' => 'Дигитално събитие', 'booking' => 'Събитие на място с резервация' ]; if ($type) { if (!empty($types[$type])) { return mb_strtolower($types[$type]) ?? null; } else { header('Location: /'); } } return $types; } public function getEventType($text = false) { $type = $this->type ?? ($_GET['type'] ?? null); $types = ['simple', 'online', 'booking']; if (!in_array($type, $types)) header('Location: /'); if ($text) $type = self::eventTypes($type); return $type; } public static function getModel() { if (!empty($_GET['id'])) { return self::findOne($_GET['id']); } else { return new Events(); } } public function get_stream_purchase_type() { return $this->stream_purchase_type ?? 'individual_price'; } public function get_stream_access() { return $this->stream_access ?? 1; } public function getPrice_objects() { return $this->hasMany(PriceObject::class, ['event_id' => 'id']); } public function setFirstLast() { if ($this->event_dates) { $dates = explode(',', $this->event_dates); sort($dates); $this->event_first_date = $dates[0]; $this->event_last_date = $dates[sizeof($dates) - 1]; } } public static function getList() { $list = []; foreach(self::find()->all() as $item) { $list[$item->id] = $item->title; } return $list; } }