예제 #1
0
 public function getAvailablePdfById($member, $pdfId)
 {
     $pdf = Pdfs::findOne(['is_active' => 1, 'id' => $pdfId]);
     $pdf_rules_match_count = $this->getPdfRule($member->id, $pdf);
     if ($pdf_rules_match_count) {
         return $pdf;
     }
     return false;
 }
예제 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pdfs::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' => $this->id, 'order' => $this->order, 'is_active' => $this->is_active, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'file', $this->file]);
     return $dataProvider;
 }
예제 #3
0
 /**
  * Finds the Pdfs model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Pdfs the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Pdfs::find()->where(['id' => $id])->multilingual()->one()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPdf()
 {
     return $this->hasOne(Pdfs::className(), ['id' => 'pdf_id']);
 }
예제 #5
0
파일: index.php 프로젝트: skamnev/members
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\PdfsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('backend', 'PDFs');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="pdfs-index">

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

    <p>
        <?php 
echo Html::a(Yii::t('backend', 'Add PDF'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'name', 'order', 'file:ntext', array('attribute' => 'is_active', 'filter' => Html::activeDropDownList($searchModel, 'is_active', \backend\models\Pdfs::dropdownActive(), ['class' => 'form-control', 'prompt' => Yii::t('backend', 'All')]), 'format' => 'boolean'), ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
?>

</div>