コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProductPost::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'product_id' => $this->product_id, 'sort_order' => $this->sort_order]);
     $query->andFilterWhere(['like', 'post_title', $this->post_title])->andFilterWhere(['like', 'post_desc', $this->post_desc]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: list_of_post.php プロジェクト: hsleonis/basetech
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use backend\models\ProductPost;
/* @var $this yii\web\View */
/* @var $model backend\models\Post */
?>
<div class="post-view">

<ul class="post_sort">

    <?php 
$posts = ProductPost::find()->where(['product_id' => $product_id])->orderBy('sort_order asc')->all();
if (!empty($posts)) {
    foreach ($posts as $value) {
        echo '<li data-id="' . $value->id . '" class="Post_' . $value->id . '">';
        echo '<div class="col-md-8">' . $value->post_title . '</div>';
        echo '<div class="col-md-4">';
        echo '<input type="button" class="btn btn-sm btn-primary view_post_btn" value="View" data_id="' . $value->id . '">';
        echo '<input type="button" class="btn btn-sm btn-default update_post_btn" value="Update" data_id="' . $value->id . '" style="margin-left:10px;">';
        echo '<input type="button" class="btn btn-sm btn-danger delete_post_btn" value="Delete" data_id="' . $value->id . '" style="margin-left:10px;">';
        echo '<span>' . $value->sort_order . '</span>';
        echo '</div>';
        echo '</li>';
    }
}
?>

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