HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux dev1 5.15.83-1-pve #1 SMP PVE 5.15.83-1 (2022-12-15T00:00Z) x86_64
User: safarimaris (1000)
PHP: 7.2.34-54+ubuntu22.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /home/safarimaris/home/safarimaris/common/models/EntityResort.php
<?php

namespace common\models;

use Yii;
use yii\db\Query;

/**
 * This is the model class for table "entity_resort".
 *
 * @property integer $id
 * @property integer $entityId
 * @property string $checkinTime
 * @property string $activities
 * @property integer $countBoat
 * @property integer $airportTransfer
 * @property integer $decompressDistance
 * @property integer $hotelTransfer
 *
 * @property Entity $entity
 */
class EntityResort extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'entity_resort';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['entityId'], 'required', 'on'=>array('create', 'update')],
            [['entityId', 'countBoat', 'airportTransfer', 'decompressDistance', 'hotelTransfer'], 'integer'],
            [['checkinTime', 'activities'], 'string', 'max' => 255],
            [['entityId'], 'exist', 'skipOnError' => true, 'targetClass' => Entity::className(), 'targetAttribute' => ['entityId' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('model', 'ID'),
            'entityId' => Yii::t('model', 'Entity ID'),
            'checkinTime' => Yii::t('model', 'Checkin time'),
            'activities' => Yii::t('model', 'Non Diving Activities'),
            'countBoat' => Yii::t('model', 'Count Boat'),
            'airportTransfer' => Yii::t('model', 'Airport Transfer'),
            'decompressDistance' => Yii::t('model', 'Decompress Distance'),
            'hotelTransfer' => Yii::t('model', 'Hotel Transfer'),
            'language' => Yii::t('model', 'Language'),
            'document' => Yii::t('model', 'Document')
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEntity()
    {
        return $this->hasOne(Entity::className(), ['id' => 'entityId']);
    }

    public function getOther($countryId)
    {
        return (new Query())
            ->select([
                'c.url',
                'e.seoUrl',
                'e.name',
            ])
            ->from('{{%entity}} e')
            ->innerJoin('{{%entity_resort}} er', 'er.entityId=e.id')
            ->innerJoin('{{%country}} c', 'c.id=e.countryId')
            ->where('c.id = :countryId AND entityId != :entityId', ['countryId' => $countryId, 'entityId' => $this->entityId])
            ->orderBy('e.ordinal, e.name')
            ->all();
    }
}