示例#1
0
 /**
  * Finds the Status model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Status the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Status::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#2
0
文件: view.php 项目: obedkin/atlant
<?php

use app\models\Status;
use app\modules\user\models\User;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model app\models\Post */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Posts'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$this->params['title_icon'] = Yii::$app->params['post']['icon'];
?>
<div class="post-view">

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'title', 'description:html', ['format' => 'raw', 'attribute' => 'created_by', 'value' => Html::a(User::findOne($model->created_by)->getName(), ['/user/view', 'id' => $model->created_by])], 'created_at:datetime', ['format' => 'raw', 'attribute' => 'created_by', 'value' => Html::a(User::findOne($model->created_by)->getName(), ['/user/view', 'id' => $model->created_by])], 'updated_at:datetime', 'weight', ['attribute' => 'status_id', 'value' => Status::findOne($model->status_id)->title]]]);
?>

</div>