/**
  * Finds the Organisation model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Organisation the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Organisation::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#2
0
?>
<div class="event-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Create Event', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['attribute' => 'owner_id', 'value' => function ($data) {
    return Organisation::findOne($data->owner_id)->name;
}], 'name', 'slug', ['attribute' => 'start_time', 'value' => function ($data) {
    return date('jS F Y', strtotime($data->start_time));
}], ['attribute' => 'end_time', 'value' => function ($data) {
    return date('jS F Y', strtotime($data->end_time));
}], ['attribute' => 'location_id', 'value' => function ($data) {
    return Location::findOne($data->location_id)->name;
}], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>