-
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
27830b5
commit 91dfeab
Showing
21 changed files
with
1,076 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace app\modules\lrm; | ||
|
||
/** | ||
* Love Relationship Management | ||
*/ | ||
class Module extends \yii\base\Module | ||
{ | ||
public $defaultRoute = 'person'; | ||
} |
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,134 @@ | ||
<?php | ||
|
||
namespace app\modules\lrm\controllers; | ||
|
||
use Yii; | ||
use app\modules\lrm\models\InteractionNote; | ||
use app\modules\lrm\models\search\InteractionNoteSearch; | ||
use yii\filters\AccessControl; | ||
use yii\web\Controller; | ||
use yii\web\NotFoundHttpException; | ||
use yii\filters\VerbFilter; | ||
|
||
/** | ||
* InteractionNoteController implements the CRUD actions for InteractionNote model. | ||
*/ | ||
class InteractionNoteController extends Controller | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function behaviors() | ||
{ | ||
return [ | ||
'access' => [ | ||
'class' => AccessControl::className(), | ||
'rules' => [ | ||
[ | ||
'allow' => true, | ||
'roles' => ['@'], | ||
], | ||
], | ||
], | ||
'verbs' => [ | ||
'class' => VerbFilter::className(), | ||
'actions' => [ | ||
'delete' => ['POST'], | ||
], | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Lists all InteractionNote models. | ||
* @return mixed | ||
*/ | ||
public function actionIndex() | ||
{ | ||
$searchModel = new InteractionNoteSearch(); | ||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
|
||
return $this->render('index', [ | ||
'searchModel' => $searchModel, | ||
'dataProvider' => $dataProvider, | ||
]); | ||
} | ||
|
||
/** | ||
* Displays a single InteractionNote model. | ||
* @param integer $id | ||
* @return mixed | ||
*/ | ||
public function actionView($id) | ||
{ | ||
return $this->render('view', [ | ||
'model' => $this->findModel($id), | ||
]); | ||
} | ||
|
||
/** | ||
* Creates a new InteractionNote model. | ||
* If creation is successful, the browser will be redirected to the 'view' page. | ||
* @return mixed | ||
*/ | ||
public function actionCreate() | ||
{ | ||
$model = new InteractionNote(); | ||
|
||
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 InteractionNote 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 InteractionNote 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 InteractionNote model based on its primary key value. | ||
* If the model is not found, a 404 HTTP exception will be thrown. | ||
* @param integer $id | ||
* @return InteractionNote the loaded model | ||
* @throws NotFoundHttpException if the model cannot be found | ||
*/ | ||
protected function findModel($id) | ||
{ | ||
if (($model = InteractionNote::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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<?php | ||
|
||
namespace app\modules\lrm\controllers; | ||
|
||
use Yii; | ||
use app\modules\lrm\models\Person; | ||
use app\modules\lrm\models\search\PersonSearch; | ||
use yii\filters\AccessControl; | ||
use yii\web\Controller; | ||
use yii\web\NotFoundHttpException; | ||
use yii\filters\VerbFilter; | ||
|
||
/** | ||
* PersonController implements the CRUD actions for Person model. | ||
*/ | ||
class PersonController extends Controller | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function behaviors() | ||
{ | ||
return [ | ||
'access' => [ | ||
'class' => AccessControl::className(), | ||
'rules' => [ | ||
[ | ||
'allow' => true, | ||
'roles' => ['@'], | ||
], | ||
], | ||
], | ||
'verbs' => [ | ||
'class' => VerbFilter::className(), | ||
'actions' => [ | ||
'delete' => ['POST'], | ||
], | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Lists all Person models. | ||
* @return mixed | ||
*/ | ||
public function actionIndex() | ||
{ | ||
$searchModel = new PersonSearch(); | ||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
|
||
return $this->render('index', [ | ||
'searchModel' => $searchModel, | ||
'dataProvider' => $dataProvider, | ||
]); | ||
} | ||
|
||
/** | ||
* Displays a single Person model. | ||
* @param integer $id | ||
* @return mixed | ||
*/ | ||
public function actionView($id) | ||
{ | ||
return $this->render('view', [ | ||
'model' => $this->findModel($id), | ||
]); | ||
} | ||
|
||
/** | ||
* Creates a new Person model. | ||
* If creation is successful, the browser will be redirected to the 'view' page. | ||
* @return mixed | ||
*/ | ||
public function actionCreate() | ||
{ | ||
$model = new Person(); | ||
|
||
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 Person 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 Person 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 Person model based on its primary key value. | ||
* If the model is not found, a 404 HTTP exception will be thrown. | ||
* @param integer $id | ||
* @return Person the loaded model | ||
* @throws NotFoundHttpException if the model cannot be found | ||
*/ | ||
protected function findModel($id) | ||
{ | ||
if (($model = Person::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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
use yii\db\Migration; | ||
|
||
class m170711_171718_createPerson extends Migration | ||
{ | ||
const TABLE = 'person'; | ||
|
||
public function up() | ||
{ | ||
$this->createTable(self::TABLE, [ | ||
'id' => $this->primaryKey(), | ||
'name' => $this->string(), | ||
'fullName' => $this->string(), | ||
'birthdate' => $this->date(), | ||
'description' => $this->string(), | ||
'gender' => $this->string(1),// f/m | ||
'createdAt' => $this->integer()->notNull(), | ||
'updatedAt' => $this->integer()->notNull(), | ||
]); | ||
} | ||
|
||
public function down() | ||
{ | ||
echo self::TABLE . ' reverted'; | ||
$this->dropTable(self::TABLE); | ||
} | ||
} |
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,45 @@ | ||
<?php | ||
|
||
use yii\db\Migration; | ||
|
||
class m170711_173037_note extends Migration | ||
{ | ||
const TABLE = 'interactionNote'; | ||
|
||
public function up() | ||
{ | ||
$this->createTable(self::TABLE, [ | ||
'id' => $this->primaryKey(), | ||
'personId' => $this->integer()->notNull(), | ||
'text' => $this->text()->notNull(), | ||
'appraisal' => $this->smallInteger(1)->notNull(),// 0 - 9 | ||
'date' => $this->date(), | ||
'createdAt' => $this->integer()->notNull(), | ||
'updatedAt' => $this->integer()->notNull(), | ||
]); | ||
|
||
$personTable = m170711_171718_createPerson::TABLE; | ||
$this->addForeignKey( | ||
'fk-inter-person', | ||
'{{%' . self::TABLE . '}}', 'personId', | ||
"{{%{$personTable}}}", 'id' | ||
); | ||
} | ||
|
||
public function down() | ||
{ | ||
echo self::TABLE . ' reverted'; | ||
$this->dropTable(self::TABLE); | ||
} | ||
|
||
/* | ||
// Use safeUp/safeDown to run migration code within a transaction | ||
public function safeUp() | ||
{ | ||
} | ||
public function safeDown() | ||
{ | ||
} | ||
*/ | ||
} |
Oops, something went wrong.