/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Mensajes::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id_Mensaje' => $this->id_Mensaje, 'id_Emisor' => $this->id_Emisor, 'id_Receptor' => $this->id_Receptor]); $query->andFilterWhere(['like', 'mensaje', $this->mensaje]); return $dataProvider; }
<h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Nuevo mensaje', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php $query = Mensajes::find()->where(['id_Receptor' => Yii::$app->user->identity->id])->all(); ?> <table class="table"> <?php foreach ($query as $data) { # code... ?> <tr> <td> <?php if ($data->leido == 1) { $leido = 'Leido'; } else { $leido = 'No leido'; } ?>
/** * Finds the Mensajes model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Mensajes the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Mensajes::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('La página solicitada no existe.'); } }
<div id="aviso"> <h1 id="titobj">Avisos</h1> <p id="desavi">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Est necessitatibus deleniti harum inventore quo! Cumque excepturi debitis officia perspiciatis nesciunt pariatur dicta omnis ab ea, iure rem sit culpa molestiae!</p> </div> </div> </section><?php } } ?> <section class="Sconten"> <?php if (!Yii::$app->user->isGuest) { $query = Mensajes::find()->where(['id_Receptor' => Yii::$app->user->identity->id])->andWhere(['!=', 'leido', '1'])->count(); // sabes xke , porque es label, no crees?? pero checate el html que se genera en el navegador //que raro // hola $menuItems = [['label' => Html::img(Yii::getAlias('@web') . "/imagenes/cliente.jpg", ['id' => 'imgEstudiante']), 'url' => '#', 'encode' => false, 'options' => ['style' => 'text-align:center; list-style: none;', 'class' => 'perfil']], ['label' => Yii::$app->user->identity->nombre . ' ' . Yii::$app->user->identity->apaterno . ' ' . Yii::$app->user->identity->amaterno, 'url' => ['/site/index'], 'options' => ['style' => 'text-align:center; font-size:18px;list-style: none;', 'class' => 'perfil']], ['label' => 'Información General', 'url' => ['/proyecto/index']]]; // ['label' => 'Modulo Incubación', 'url' => '#','options' =>['class' =>'menu2 menu'],'items' => [ // ['label' => 'Canvas', 'url' => ['product/index']], // ['label' => 'Modelo de negocios', 'url' => ['product/index']], // 'options' =>['class' =>'nav nav-bar borde'], // ]], if (Yii::$app->user->identity->id_rol == 1) { # code... $menuItems[] = ['label' => 'Roles', 'url' => ['/rol/index']]; $menuItems[] = ['label' => 'Permisos', 'url' => ['/operacion/index']]; $menuItems[] = ['label' => 'Mensajes <span class="badge">' . $query . '</span>', 'url' => ['/mensajes/index'], 'encode' => false]; if (Yii::$app->controller->id == 'proyecto' && Yii::$app->controller->action->id == 'view') {