/** * Проверка на уникальность записи * @param $url * @return bool */ public function productUnique($url) { $model = Items::find()->where(['url' => $url])->all(); if ($model) { return false; } else { return true; } }
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); } }
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(); }
/** * Lists all Items models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Items::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
public static function productUnique($url) { return !Items::find()->where(['url' => $url])->exists(); }