예제 #1
0
파일: Rst.php 프로젝트: Sywooch/find-parser
 /**
  * Проверка на уникальность записи
  * @param $url
  * @return bool
  */
 public function productUnique($url)
 {
     $model = Items::find()->where(['url' => $url])->all();
     if ($model) {
         return false;
     } else {
         return true;
     }
 }
예제 #2
0
 public function actionIndex()
 {
     if (User::isAdmin(Yii::$app->user->identity->username)) {
         $link = new ActiveDataProvider(['query' => Items::find(), 'pagination' => ['pageSize' => 50]]);
         return $this->render('index', compact('link'));
     } else {
         throw new ForbiddenHttpException('У вас нет прав администратора!', 404);
     }
 }
예제 #3
0
 public function actionDelete($id)
 {
     $userId = Yii::$app->user->id ? Yii::$app->user->id : 0;
     $items = Items::find()->where(['items.id' => $id, "items.trash" => 0, "items.seller_id" => $userId])->one();
     if ($items === null) {
         return new Items();
     }
     $items->trash = 1;
     $items->save();
     //unset($this);
     //print_r($items); die();
     return new Items();
 }
예제 #4
0
 /**
  * Lists all Items models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Items::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
예제 #5
0
 public static function productUnique($url)
 {
     return !Items::find()->where(['url' => $url])->exists();
 }