/** * Изменение формата времени у экземпляра класса <b>Doctors</b> * старый формат <b>чч</b>:<b>мм</b> * выходной формат - количество минут от полночи: <b>часы</b> * 60 + <b>минуты</b> * @param \frontend\modules\doctors\models\Doctors $model экземпляр класса <b>Doctors</b> */ private function changeTimeFormat(&$model) { $start_time = explode(':', $model->start_time); if (count($start_time) == 2) { $model->start_time = Doctors::timeToInt($model->start_time); $model->end_time = Doctors::timeToInt($model->end_time); } else { $model->start_time = Doctors::timeToString($model->start_time); $model->end_time = Doctors::timeToString($model->end_time); } }
<p> <?php echo Html::a('Добавить врача', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'name', 'format' => 'raw', 'value' => function ($model) { $url = '/doctors/default/view?id=' . $model->id; $result = Html::a($model->name, $url, []); return $result; }], 'number', 'description:ntext', 'phone', ['attribute' => 'start_time', 'format' => 'raw', 'value' => function ($model) { if (is_numeric($model->start_time) && $model->start_time > 0) { $result = Doctors::timeToString($model->start_time); } else { $result = '<span class="text-danger">Не задано</span>'; } return $result; }], ['attribute' => 'end_time', 'format' => 'raw', 'value' => function ($model) { if (is_numeric($model->end_time) && $model->end_time > 0) { $result = Doctors::timeToString($model->end_time); } else { $result = '<span class="text-danger">Не задано</span>'; } return $result; }], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>