public function actionCreate()
 {
     $result = 0;
     if (Yii::$app->request->isPost && ($model = ProductFollowing::create(Yii::$app->request->post()))) {
         if ($model->hasErrors()) {
             $result = json_encode($model->getErrors());
         } else {
             $result = 1;
         }
     }
     return $result;
 }
Exemple #2
0
 /**
  * function ::create ($data)
  */
 public static function create($data)
 {
     $now = strtotime('now');
     $model = new ProductFollowing();
     if ($model->load($data)) {
         $model->created_at = $now;
         $model->status = 0;
         if ($model->save()) {
             return $model;
         }
         $model->getErrors();
         return $model;
     }
     return false;
 }