<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "optional_service".
 *
 * @property int $id
 * @property string $name
 * @property float $price
 */
class OptionalService extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'optional_service';
    }

    public static function getPriceByID($service_id)
    {
        $service = OptionalService::findOne($service_id);
        if($service != null){
            return $service->price;
        }else{
            return 0;
        }
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['name', 'price'], 'required'],
            [['price'], 'number'],
            [['name'], 'string', 'max' => 200],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'name' => Yii::t('app', 'Name'),
            'price' => Yii::t('app', 'Price'),
        ];
    }
}
