public function actionDeletePost() { $selection = (array) Yii::$app->request->post('selection'); foreach ($selection as $id) { Post::deleteAll(['id' => $id]); Like::deleteAll(['post_id' => $id]); Comment::deleteAll(['post_id' => $id]); PostTag::deleteAll(['post_id' => $id]); PostNotification::deleteAll(['post_id' => $id]); PostProtected::deleteAll(['post_id' => $id]); } return $this->render('post-manage'); }
public function testCreate(AcceptanceTester $I) { $I->wantTo('ensure that create post works'); $createPage = CreatePage::openBy($I); $I->see('Add New Post', 'h1'); $I->see('Categories'); $I->see('Tags'); $I->amGoingTo('submit create post form with no data'); $createPage->submit([]); $I->expectTo('see validation errors'); $I->see('Title cannot be blank.', '.help-block'); $I->amGoingTo('submit create post form with same title'); $createPage->submit(['post_title' => 'Sample Post']); $I->expectTo('see that title already taken'); $I->see('Title "Sample Post" has already been taken.', '.help-block'); $I->amGoingTo('submit create post form with correct data'); $createPage->submit(['post_title' => 'New Test Post Title', 'post_slug' => 'new-test-post-title', 'post_content' => 'New Test Post Content']); $I->expect('new post saved'); $I->see('Post successfully saved.', '.alert'); Post::deleteAll(['post_title' => 'New Test Post Title']); }
/** * Deletes an existing Thread model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { if (!YiiForum::checkAuth('thread_delete')) { return $this->noPermission(); } YiiForum::checkIsGuest(); $thread = $this->findModel($id); $thread->delete(); Post::deleteAll(['thread_id' => $thread['id']]); return $this->redirect(['index', 'boardid' => $thread['board_id']]); }
/** * Deletes an existing Thread model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $this->checkIsGuest(); $thread = $this->findModel($id); $thread->delete(); Post::deleteAll(['thread_id' => $thread['id']]); return $this->redirect(['index', 'boardid' => $thread['board_id']]); }