/** * function ::create ($data) */ public static function create($data) { $now = strtotime('now'); $username = Yii::$app->user->identity->username; $model = new Currency(); if ($model->load($data)) { if ($log = new UserLog()) { $log->username = $username; $log->action = "Create"; $log->object_class = "Currency"; $log->created_at = $now; $log->is_success = 0; $log->save(); } $model->created_at = $now; $model->created_by = $username; if ($model->save()) { if ($log) { $log->object_pk = $model->id; $log->is_success = 1; $log->save(); } return $model; } $model->getErrors(); return $model; } return false; }
/** * Creates a new Currency model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Currency(); $billings = Billing::getAssocBillings(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model, 'billings' => $billings]); } }