コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Artikel::find();
     $query->orderBy(['id' => SORT_DESC]);
     $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, 'author' => $this->author, 'categori_id' => $this->categori_id, 'schedule_date' => $this->schedule_date, 'status' => $this->status, 'viewed' => $this->viewed, 'user_create' => $this->user_create, 'user_update' => $this->user_update, 'date_create' => $this->date_create, 'date_update' => $this->date_update]);
     $query->andFilterWhere(['like', 'judul', $this->judul])->andFilterWhere(['like', 'summary', $this->summary])->andFilterWhere(['like', 'deskripsi', $this->deskripsi])->andFilterWhere(['like', 'author_name', $this->author_name])->andFilterWhere(['like', 'categori_name', $this->categori_name])->andFilterWhere(['like', 'sumber', $this->sumber])->andFilterWhere(['like', 'image1', $this->image1])->andFilterWhere(['like', 'image2', $this->image2])->andFilterWhere(['like', 'image3', $this->image3])->andFilterWhere(['like', 'image4', $this->image4])->andFilterWhere(['like', 'image5', $this->image5])->andFilterWhere(['like', 'image6', $this->image6])->andFilterWhere(['like', 'image7', $this->image7])->andFilterWhere(['like', 'image8', $this->image8])->andFilterWhere(['like', 'image9', $this->image9])->andFilterWhere(['like', 'video', $this->video])->andFilterWhere(['like', 'user_by', $this->user_by]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: view.php プロジェクト: iwansusanto/jurnalrumah
use backend\assets\ArtikelAsset;
use backend\models\Artikel;
/* @var $this yii\web\View */
/* @var $model backend\models\Artikel */
ArtikelAsset::register($this);
$this->title = $model->judul;
$this->params['breadcrumbs'][] = ['label' => 'Artikels', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="artikel-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

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

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'judul', 'summary', 'deskripsi:ntext', 'author_name', 'categori_name', 'sumber', 'schedule_date', ['label' => 'Status', 'value' => Artikel::getStatus($model->status)], ['label' => 'Image File', 'type' => 'row', 'format' => ['image', ['width' => '150', 'height' => '100', 'alt' => $model->judul]], 'value' => !empty($model->image1) ? \Yii::$app->jurnalrumah->lihatImageDetail($model->image1, "", $kategori = "artikel") : NULL], ['label' => 'Image File 2', 'type' => 'row', 'format' => ['image', ['width' => '150', 'height' => '100', 'alt' => $model->judul]], 'value' => !empty($model->image2) ? \Yii::$app->jurnalrumah->lihatImageDetail($model->image2, "", $kategori = "artikel") : NULL], ['label' => 'Image File 3', 'type' => 'row', 'format' => ['image', ['width' => '150', 'height' => '100', 'alt' => $model->judul]], 'value' => !empty($model->image3) ? \Yii::$app->jurnalrumah->lihatImageDetail($model->image3, "", $kategori = "artikel") : NULL], ['label' => 'Image File 4', 'type' => 'row', 'format' => ['image', ['width' => '150', 'height' => '100', 'alt' => $model->judul]], 'value' => !empty($model->image4) ? \Yii::$app->jurnalrumah->lihatImageDetail($model->image4, "", $kategori = "artikel") : NULL], ['label' => 'Image File 5', 'type' => 'row', 'format' => ['image', ['width' => '150', 'height' => '100', 'alt' => $model->judul]], 'value' => !empty($model->image5) ? \Yii::$app->jurnalrumah->lihatImageDetail($model->image5, "", $kategori = "artikel") : NULL], ['label' => 'Image File 6', 'type' => 'row', 'format' => ['image', ['width' => '150', 'height' => '100', 'alt' => $model->judul]], 'value' => !empty($model->image6) ? \Yii::$app->jurnalrumah->lihatImageDetail($model->image6, "", $kategori = "artikel") : NULL], ['label' => 'Image File 7', 'type' => 'row', 'format' => ['image', ['width' => '150', 'height' => '100', 'alt' => $model->judul]], 'value' => !empty($model->image7) ? \Yii::$app->jurnalrumah->lihatImageDetail($model->image7, "", $kategori = "artikel") : NULL], ['label' => 'Image File 8', 'type' => 'row', 'format' => ['image', ['width' => '150', 'height' => '100', 'alt' => $model->judul]], 'value' => !empty($model->image8) ? \Yii::$app->jurnalrumah->lihatImageDetail($model->image8, "", $kategori = "artikel") : NULL], ['label' => 'Image File 9', 'type' => 'row', 'format' => ['image', ['width' => '150', 'height' => '100', 'alt' => $model->judul]], 'value' => !empty($model->image9) ? \Yii::$app->jurnalrumah->lihatImageDetail($model->image9, "", $kategori = "artikel") : NULL], 'video:ntext', 'date_create', 'date_update', 'tag']]);
?>

</div>
コード例 #3
0
ファイル: ArtikelKategori.php プロジェクト: cakpep/spk-tht
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getArtikels()
 {
     return $this->hasMany(Artikel::className(), ['kategori_id' => 'id']);
 }
コード例 #4
0
ファイル: index.php プロジェクト: iwansusanto/jurnalrumah
/* @var $dataProvider yii\data\ActiveDataProvider */
ArtikelAsset::register($this);
$this->title = 'Artikels';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="artikel-index">

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

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

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'id', 'format' => 'raw', 'value' => function ($model) {
    return "#" . $model->id;
}], 'judul', 'summary:ntext', 'schedule_date', ['attribute' => 'status', 'format' => 'raw', 'value' => function ($model) {
    return Artikel::getStatus($model->status);
}], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
コード例 #5
0
 /**
  * Finds the Artikel model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Artikel the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Artikel::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #6
0
ファイル: _form.php プロジェクト: iwansusanto/jurnalrumah
    <?php 
echo $form->field($model, 'schedule_date')->widget(DateTimePicker::className(), ['language' => 'en', 'size' => 'ms', 'template' => '{input}', 'pickButtonIcon' => 'glyphicon glyphicon-time', 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-m-dd hh:ii', 'todayBtn' => true]]);
?>
    <?php 
echo Html::activeLabel($model, 'tag');
?>
    <?php 
echo SelectizeTextInput::widget(['model' => $model->tag, 'name' => 'Artikel[tag]', 'id' => 'artikel-tag', 'value' => $model->isNewRecord ? '' : $model->tag, 'clientOptions' => ['plugins' => ['remove_button'], 'delimiter' => ',', 'persist' => false, 'create' => 'function(input){
                    return {
                        value   :   input,
                        text    :   input
                    }
                }']]);
?>
    <?php 
echo $form->field($model, 'status', ['template' => "{label}{input}\n{hint}\n{error}"])->dropDownList(Artikel::getStatus(), ['prompt' => '-- Pilih --']);
?>
    
    <?php 
// $form->field($model, 'video')->textarea(['rows' => 6])
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>