/
k6011565
/
UP09
Обзор
Документация
Войти
/
k6011565
/
UP09
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
basic/models/Tour.php
47 строк
1 KB
Карина Коковкина
все файлы
24 июн 2026, 15:42
24 июн 2026, 15:42
2a8b11b
Код
Авторство
О чём код?
<?php namespace app\models; use yii\db\ActiveRecord; class Tour extends ActiveRecord { public static function tableName() { return 'tour'; } public function rules() { return [ [['title', 'destination', 'type', 'duration', 'price'], 'required'], [['description', 'image'], 'string'], [['duration', 'max_people'], 'integer'], [['price'], 'number'], [['start_date', 'end_date'], 'date', 'format' => 'php:Y-m-d'], [['title', 'destination', 'type'], 'string', 'max' => 255], ]; } public function getBookings() { return $this->hasMany(Booking::class, ['tour_id' => 'id']); } public function getReviews() { return $this->hasMany(Review::class, ['tour_id' => 'id']); } public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($this->isNewRecord) { $this->created_at = time(); } $this->updated_at = time(); return true; } return false; } }