예제 #1
0
파일: _item.php 프로젝트: skamnev/members
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\data\ActiveDataProvider;
use frontend\models\DiaryNutrition;
$diaryDate = date('m-d-Y', strtotime($model->created_at));
$dataProvider = new ActiveDataProvider(['query' => DiaryNutrition::find()->where(['=', "DATE_FORMAT(created_at,'%m-%d-%Y')", $diaryDate])->andWhere(['member_id' => Yii::$app->getUser()->id])->orderBy('created_at ASC')]);
?>

<div class="diary-item">
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'summary' => $diaryDate == date('m-d-Y') ? Yii::t('frontend', 'Today') : $diaryDate, 'columns' => [['attribute' => 'created_at', 'label' => Yii::t('frontend', 'Time'), 'format' => ['date', 'php:H:i']], ['attribute' => 'value', 'label' => Yii::t('frontend', 'Meal')], 'comment', ['class' => 'yii\\grid\\ActionColumn', 'visible' => false, 'template' => '']]]);
?>
</div>
예제 #2
0
 protected function findModel($id)
 {
     if (($model = DiaryNutrition::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }