fix

parent 8de0928f
......@@ -36,19 +36,13 @@ class BidController extends \common\components\BaseController
$model = new Bid;
$model->scenario = Yii::$app->request->post('scenario');
if(Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()))
{
if(Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
$transaction = Yii::$app->db->beginTransaction();
try
{
if($model->save())
{
try {
if ($model->save()) {
// Yii::$app->user->identity->afterSubscribe(12);
if($model->file)
{
foreach ($model->file as $filename)
{
if ($model->file) {
foreach ($model->file as $filename) {
$file = new BidFile;
$file->bid_id = $model->id;
$file->filename = $filename;
......@@ -58,24 +52,17 @@ class BidController extends \common\components\BaseController
}
$model->send();
$transaction->commit();
return ['success' => true];
}
else
{
} else {
return ActiveForm::validate($model);
}
}
catch (Exception $e)
{
} catch (Exception $e) {
$transaction->rollBack();
throw $e;
}
}
else
{
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
......@@ -92,19 +79,12 @@ class BidController extends \common\components\BaseController
$model = new Bid;
$model->blog = true;
$model->scenario = Yii::$app->request->post('scenario');
if(Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()))
{
if(Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
$transaction = Yii::$app->db->beginTransaction();
try
{
if($model->save())
{
// Yii::$app->user->identity->afterSubscribe(12);
if($model->file)
{
foreach ($model->file as $filename)
{
try {
if ($model->save()) {
if ($model->file) {
foreach ($model->file as $filename) {
$file = new BidFile;
$file->bid_id = $model->id;
$file->filename = $filename;
......@@ -114,24 +94,17 @@ class BidController extends \common\components\BaseController
}
$model->send();
$transaction->commit();
return ['success' => true];
}
else
{
} else {
return ActiveForm::validate($model);
}
}
catch (Exception $e)
{
} catch (Exception $e) {
$transaction->rollBack();
throw $e;
}
}
else
{
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
......@@ -144,10 +117,8 @@ class BidController extends \common\components\BaseController
$model = new BidFile;
$model->file = UploadedFile::getInstanceByName('file');
if($model->file)
{
if(!file_exists(BidFile::path()))
{
if($model->file) {
if (!file_exists(BidFile::path())) {
mkdir(BidFile::path(), 0777, true);
}
......
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