-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91dfeab
commit f915124
Showing
15 changed files
with
377 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?php | ||
|
||
namespace app\modules\lrm\controllers; | ||
|
||
use Yii; | ||
use app\modules\lrm\models\PersonState; | ||
use yii\data\ActiveDataProvider; | ||
use yii\web\Controller; | ||
use yii\web\NotFoundHttpException; | ||
use yii\filters\VerbFilter; | ||
|
||
/** | ||
* PersonStateController implements the CRUD actions for PersonState model. | ||
*/ | ||
class PersonStateController extends Controller | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function behaviors() | ||
{ | ||
return [ | ||
'verbs' => [ | ||
'class' => VerbFilter::className(), | ||
'actions' => [ | ||
'delete' => ['POST'], | ||
], | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Lists all PersonState models. | ||
* @return mixed | ||
*/ | ||
public function actionIndex() | ||
{ | ||
$dataProvider = new ActiveDataProvider([ | ||
'query' => PersonState::find(), | ||
]); | ||
|
||
return $this->render('index', [ | ||
'dataProvider' => $dataProvider, | ||
]); | ||
} | ||
|
||
/** | ||
* Displays a single PersonState model. | ||
* @param integer $id | ||
* @return mixed | ||
*/ | ||
public function actionView($id) | ||
{ | ||
return $this->render('view', [ | ||
'model' => $this->findModel($id), | ||
]); | ||
} | ||
|
||
/** | ||
* Creates a new PersonState model. | ||
* If creation is successful, the browser will be redirected to the 'view' page. | ||
* @return mixed | ||
*/ | ||
public function actionCreate() | ||
{ | ||
$model = new PersonState(); | ||
|
||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
return $this->redirect(['view', 'id' => $model->id]); | ||
} else { | ||
return $this->render('create', [ | ||
'model' => $model, | ||
]); | ||
} | ||
} | ||
|
||
/** | ||
* Updates an existing PersonState 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]); | ||
} else { | ||
return $this->render('update', [ | ||
'model' => $model, | ||
]); | ||
} | ||
} | ||
|
||
/** | ||
* Deletes an existing PersonState 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 PersonState model based on its primary key value. | ||
* If the model is not found, a 404 HTTP exception will be thrown. | ||
* @param integer $id | ||
* @return PersonState the loaded model | ||
* @throws NotFoundHttpException if the model cannot be found | ||
*/ | ||
protected function findModel($id) | ||
{ | ||
if (($model = PersonState::findOne($id)) !== null) { | ||
return $model; | ||
} else { | ||
throw new NotFoundHttpException('The requested page does not exist.'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
use yii\db\Migration; | ||
|
||
class m170712_181655_leadPerson extends Migration | ||
{ | ||
const TABLE = 'personState'; | ||
const FK = 'fk-pers-persState'; | ||
public $tableFk = 'person'; | ||
|
||
public function up() | ||
{ | ||
$table = $this->tableFk;//m170711_171718_createPerson::TABLE; | ||
|
||
$this->addColumn($table, 'stateId', $this->integer()->null()); | ||
|
||
$this->createTable(self::TABLE, [ | ||
'id' => $this->primaryKey(), | ||
'name' => $this->string(), | ||
]); | ||
|
||
$this->addForeignKey( | ||
self::FK, | ||
$table, 'stateId', | ||
self::TABLE, 'id' | ||
); | ||
|
||
} | ||
|
||
public function down() | ||
{ | ||
$this->dropForeignKey(self::FK, $this->tableFk); | ||
$this->dropColumn($this->tableFk, 'stateId'); | ||
$this->dropTable(self::TABLE); | ||
} | ||
|
||
/* | ||
// Use safeUp/safeDown to run migration code within a transaction | ||
public function safeUp() | ||
{ | ||
} | ||
public function safeDown() | ||
{ | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace app\modules\lrm\models; | ||
|
||
use Yii; | ||
|
||
/** | ||
* //todo: order property for sorting | ||
* This is the model class for table "{{%personState}}". | ||
* | ||
* @property integer $id | ||
* @property string $name | ||
* | ||
* @property Person[] $people | ||
*/ | ||
class PersonState extends \yii\db\ActiveRecord | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public static function tableName() | ||
{ | ||
return '{{%personState}}'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
[['name'], 'string', 'max' => 255], | ||
]; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function attributeLabels() | ||
{ | ||
return [ | ||
'id' => 'ID', | ||
'name' => 'Name', | ||
]; | ||
} | ||
|
||
/** | ||
* @return \yii\db\ActiveQuery | ||
*/ | ||
public function getPeople() | ||
{ | ||
return $this->hasMany(Person::className(), ['stateId' => 'id']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
use yii\helpers\Html; | ||
use yii\widgets\ActiveForm; | ||
|
||
/* @var $this yii\web\View */ | ||
/* @var $model app\modules\lrm\models\PersonState */ | ||
/* @var $form yii\widgets\ActiveForm */ | ||
?> | ||
|
||
<div class="person-state-form"> | ||
|
||
<?php $form = ActiveForm::begin(); ?> | ||
|
||
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> | ||
|
||
<div class="form-group"> | ||
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | ||
</div> | ||
|
||
<?php ActiveForm::end(); ?> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use yii\helpers\Html; | ||
|
||
|
||
/* @var $this yii\web\View */ | ||
/* @var $model app\modules\lrm\models\PersonState */ | ||
|
||
$this->title = 'Create Person State'; | ||
$this->params['breadcrumbs'][] = ['label' => 'Person States', 'url' => ['index']]; | ||
$this->params['breadcrumbs'][] = $this->title; | ||
?> | ||
<div class="person-state-create"> | ||
|
||
<h1><?= Html::encode($this->title) ?></h1> | ||
|
||
<?= $this->render('_form', [ | ||
'model' => $model, | ||
]) ?> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
use yii\helpers\Html; | ||
use yii\grid\GridView; | ||
|
||
/* @var $this yii\web\View */ | ||
/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
|
||
$this->title = 'Person States'; | ||
$this->params['breadcrumbs'][] = $this->title; | ||
?> | ||
<div class="person-state-index"> | ||
|
||
<h1><?= Html::encode($this->title) ?></h1> | ||
|
||
<p> | ||
<?= Html::a('Create Person State', ['create'], ['class' => 'btn btn-success']) ?> | ||
</p> | ||
<?= GridView::widget([ | ||
'dataProvider' => $dataProvider, | ||
'columns' => [ | ||
['class' => 'yii\grid\SerialColumn'], | ||
|
||
'id', | ||
'name', | ||
|
||
['class' => 'yii\grid\ActionColumn'], | ||
], | ||
]); ?> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use yii\helpers\Html; | ||
|
||
/* @var $this yii\web\View */ | ||
/* @var $model app\modules\lrm\models\PersonState */ | ||
|
||
$this->title = 'Update Person State: ' . $model->name; | ||
$this->params['breadcrumbs'][] = ['label' => 'Person States', 'url' => ['index']]; | ||
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; | ||
$this->params['breadcrumbs'][] = 'Update'; | ||
?> | ||
<div class="person-state-update"> | ||
|
||
<h1><?= Html::encode($this->title) ?></h1> | ||
|
||
<?= $this->render('_form', [ | ||
'model' => $model, | ||
]) ?> | ||
|
||
</div> |
Oops, something went wrong.