add fingerpint rest

This commit is contained in:
2020-01-06 10:50:57 +01:00
parent 14a5fbed33
commit b05f861667
13 changed files with 637 additions and 0 deletions

View File

@@ -0,0 +1,121 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Fingerprint;
use backend\models\FingerprintSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* FingerprintController implements the CRUD actions for Fingerprint model.
*/
class FingerprintController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all Fingerprint models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new FingerprintSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Fingerprint model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Fingerprint model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Fingerprint();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_fingerprint]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing Fingerprint 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->id_fingerprint]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Fingerprint 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 Fingerprint model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Fingerprint the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Fingerprint::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@@ -0,0 +1,69 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Fingerprint;
/**
* FingerprintSearch represents the model behind the search form about `common\models\Fingerprint`.
*/
class FingerprintSearch extends Fingerprint
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_fingerprint', 'id_customer'], 'integer'],
[['fingerprint', 'created_at', 'updated_at'], '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 = Fingerprint::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_fingerprint' => $this->id_fingerprint,
'id_customer' => $this->id_customer,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'fingerprint', $this->fingerprint]);
return $dataProvider;
}
}

View File

@@ -0,0 +1,29 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Fingerprint */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="fingerprint-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'id_customer')->textInput() ?>
<?= $form->field($model, 'fingerprint')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'created_at')->textInput() ?>
<?= $form->field($model, 'updated_at')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/fingerprint', 'Create') : Yii::t('common/fingerprint', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@@ -0,0 +1,35 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\FingerprintSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="fingerprint-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id_fingerprint') ?>
<?= $form->field($model, 'id_customer') ?>
<?= $form->field($model, 'fingerprint') ?>
<?= $form->field($model, 'created_at') ?>
<?= $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton(Yii::t('common/fingerprint', 'Search'), ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('common/fingerprint', 'Reset'), ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Fingerprint */
$this->title = Yii::t('common/fingerprint', 'Create Fingerprint');
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/fingerprint', 'Fingerprints'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="fingerprint-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@@ -0,0 +1,38 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\FingerprintSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common/fingerprint', 'Fingerprints');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="fingerprint-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('common/fingerprint', 'Create Fingerprint'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id_fingerprint',
'id_customer',
'fingerprint:ntext',
'created_at',
'updated_at',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Fingerprint */
$this->title = Yii::t('common/fingerprint', 'Update {modelClass}: ', [
'modelClass' => 'Fingerprint',
]) . ' ' . $model->id_fingerprint;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/fingerprint', 'Fingerprints'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id_fingerprint, 'url' => ['view', 'id' => $model->id_fingerprint]];
$this->params['breadcrumbs'][] = Yii::t('common/fingerprint', 'Update');
?>
<div class="fingerprint-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@@ -0,0 +1,39 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Fingerprint */
$this->title = $model->id_fingerprint;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/fingerprint', 'Fingerprints'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="fingerprint-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('common/fingerprint', 'Update'), ['update', 'id' => $model->id_fingerprint], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('common/fingerprint', 'Delete'), ['delete', 'id' => $model->id_fingerprint], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('common/fingerprint', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id_fingerprint',
'id_customer',
'fingerprint:ntext',
'created_at',
'updated_at',
],
]) ?>
</div>