<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "table".
 *
 * @property int $id
 * @property string|null $name
 * @property int|null $places
 * @property string|null $type
 * @property string|null $slug
 *
 * @property Order[] $orders
 */
class Table extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'table';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['places'], 'integer'],
            [['name', 'type', 'slug'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'places' => 'Places',
            'type' => 'Type',
            'slug' => 'Slug',
        ];
    }

    /**
     * Gets query for [[Orders]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getOrders()
    {
        return $this->hasMany(Order::class, ['table_id' => 'id']);
    }
}
