Commit 2a4b3007 authored by Shakarim Sapa's avatar Shakarim Sapa

- Добавили метод, добавляющий кейс в базу

parent 659a51a6
......@@ -8,6 +8,7 @@
namespace common\modules\cases\controllers;
use common\modules\content\models\CoContent;
use Yii;
use common\components\AdminController;
use common\modules\content\models\SearchCoContent;
......@@ -16,7 +17,8 @@ class CasesAdminController extends AdminController {
public static function actionsTitles(){
return [
'Manage' => 'Управление кейсами',
'Create' => 'Добавление кейса',
'Createcase' => 'Добавление кейса',
'Createproject' => 'Добавление проекта',
'Update' => 'Редактирование кейса',
'View' => 'Просмотр кейса',
'Delete' => 'Удаление кейса',
......@@ -39,4 +41,48 @@ class CasesAdminController extends AdminController {
]
);
}
/**
* @return string|\yii\web\Response
* @throws \Exception
*/
public function actionCreatecase()
{
$model = new CoContent;
Yii::$app->controller->page_title = 'Добавить кейс';
Yii::$app->controller->breadcrumbs = [
[
'Управление кейсами' => \yii\helpers\Url::toRoute('manage')
],
'Добавить кейс',
];
if (Yii::$app->request->isPost)
{
$transaction = Yii::$app->db->beginTransaction();
try
{
$model->attributes = Yii::$app->request->post('CoContent');
if($model->save())
{
$transaction->commit();
return $this->redirect(['manage']);
}
}
catch (\Exception $e)
{
$transaction->rollBack();
throw $e;
}
}
return $this->render('create', [
'model' => $model,
'id' => 4
]);
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment