I’m using this Joli Angular theme here daveismyname(.)com/free-bootstrap-admin-themes-bp
I created the search feature using CRUD.
However the search and delete is not working
my model
<?php
namespace app\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use app\models\TTGoTransaksi;
/**
* TtgotransaksiSearch represents the model behind the search form about `app\models\TTGoTransaksi`.
*/
class TtgotransaksiSearch extends TTGoTransaksi
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['NIM', 'No_Transaksi', 'Total_Pembayaran'], 'integer'],
[['NAMA', 'Metode_Pembayaran', 'Tanggal_transaksi', 'Nama_Kasir'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = TTGoTransaksi::find();
// add conditions that should always apply here
$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;
}
// grid filtering conditions
$query->andFilterWhere([
'NIM' => $this->NIM,
'No_Transaksi' => $this->No_Transaksi,
'Total_Pembayaran' => $this->Total_Pembayaran,
'Tanggal_transaksi' => $this->Tanggal_transaksi,
]);
$query->andFilterWhere(['like', 'NAMA', $this->NAMA])
->andFilterWhere(['like', 'Metode_Pembayaran', $this->Metode_Pembayaran])
->andFilterWhere(['like', 'Nama_Kasir', $this->Nama_Kasir]);
return $dataProvider;
}
}
My controller
<?php
namespace app\controllers;
use Yii;
use app\models\TTGoTransaksi;
use app\models\TtgotransaksiSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* TtgotransaksiController implements the CRUD actions for TTGoTransaksi model.
*/
class TtgotransaksiController extends Controller
{
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['GET'],
],
],
];
}
/**
* Lists all TTGoTransaksi models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new TtgotransaksiSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single TTGoTransaksi model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new TTGoTransaksi model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new TTGoTransaksi();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->No_Transaksi]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing TTGoTransaksi model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->No_Transaksi]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing TTGoTransaksi model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the TTGoTransaksi model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return TTGoTransaksi the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = TTGoTransaksi::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
my view
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model app\models\TtgotransaksiSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="ttgo-transaksi-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'NIM') ?>
<?= $form->field($model, 'NAMA') ?>
<?= $form->field($model, 'No_Transaksi') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
I need the help please