本文整理汇总了PHP中Post::destroy方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::destroy方法的具体用法?PHP Post::destroy怎么用?PHP Post::destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::destroy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Post
function _test_should_return_false_when_destroy_fails()
{
$this->installAndIncludeModels('Post');
$Post = new Post(array('title' => 'A Title'));
$Post->save();
$this->assertTrue($Post->destroy());
$this->assertFalse($Post->destroy());
}
示例2: destroy
public function destroy($id)
{
$post = Post::findOrFail($id);
$this->authorOrAdminPermissioinRequire($post->user_id);
Post::destroy($id);
Flash::success(lang('Operation succeeded.'));
return Redirect::route('posts.index');
}
示例3: _list
public static function _list()
{
$warning = "";
if (isset($_POST['delete_post'])) {
///check if a user is logged in and if the logged in user is the one that wrote the blog post
if (isset($_SESSION['user_id']) && $_SESSION['user_id'] == $_POST['user_id']) {
Post::destroy($_POST['id']);
} else {
$warning = 'Sorry, you do not have permissions to delete that post';
}
}
if (isset($_POST['update_post'])) {
///check if a user is logged in and if the logged in user is the one that wrote the blog post
if (isset($_SESSION['user_id']) && $_SESSION['user_id'] == $_POST['user_id']) {
Post::edit($_POST, $_POST['id']);
} else {
$warning = 'Sorry, you do not have permissions to edit that post';
}
}
if (isset($_POST['create_post'])) {
///check if a user is logged in
if (isset($_SESSION['user_id'])) {
$_POST['user_id'] = $_SESSION['user_id'];
Post::create($_POST);
} else {
$warning = 'Sorry, you must be logged in to submit a post';
}
}
$posts_array = Post::getAll();
if ($posts_array) {
foreach ($posts_array as $post) {
$blogger = Blogger::getOne($post['user_id']);
$post['username'] = $blogger['username'];
}
}
return array('posts' => $posts_array, 'warning' => $warning);
}
示例4: eliminar
public function eliminar($id)
{
Post::destroy($id);
}
示例5: it_destroys_the_model_with_the_given_id
/** @test **/
public function it_destroys_the_model_with_the_given_id()
{
$this->createPostsTable();
$this->insertOn('posts', ['title' => 'House', 'content' => 'Repeating']);
$this->insertOn('posts', ['title' => 'Sherlock', 'content' => 'Elementary Watson.']);
$this->insertOn('posts', ['title' => 'Psych!', 'content' => 'Repeating']);
$this->assertEquals(3, Object::count());
Post::destroy(2);
$this->assertEquals(2, Object::count());
}
示例6: delete_article
public function delete_article($id)
{
$postInstance = Post::findOrFail($id);
$postAuthor = $postInstance->user()->first();
if (!Auth::user()->isAdmin() && Auth::user()->username != $postAuthor->username) {
return Redirect::route('login');
} else {
// Also delete all comments:
$commentsArray = $postInstance->comments()->get();
foreach ($commentsArray as $oneComment) {
Comment::destroy($oneComment->id);
}
Post::destroy($id);
return Redirect::route("home");
}
}
示例7: destroy
/**
* Remove the specified resource from storage.
*
* @param int/array $id
* @return Response
*/
public function destroy($id)
{
// delete base on id
$post = Post::destroy(explode(',', $id));
if ($post == 0) {
// no resource deleted, return error object
return $this->postService->notFound(explode(',', $id));
}
// otherwise return delete response
return $this->postService->deletePostOkResponse();
}
示例8: destroy
/**
* Remove the specified post from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
Post::destroy($id);
return Redirect::route('admin.posts.index')->with('message', 'Data berhasil dihapus');
}
示例9: delete
/**
* Remove the specified post from storage.
*
* @param int $id
* @return Response
*/
public function delete($id)
{
Post::destroy($id);
return Redirect::back();
}
示例10: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
Post::destroy($id);
return Redirect::action('PostsController@index');
}
示例11: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$post = Post::find($id);
$this->deletePostImages($post);
Post::destroy($id);
return Redirect::to('admin/posts')->with(array('note' => 'Successfully Deleted Post', 'note_type' => 'success'));
}
示例12: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
Post::destroy($id);
//$post = findOrFail($id);
return Redirect::route('posts.index');
}
示例13: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
if (Auth::check()) {
$post = Post::find($id);
$topic = $post->topic->id;
Post::destroy($id);
return Redirect::action('TopicController@show', array($topic))->with('message', 'Post deleted successfully');
} else {
return Redirect::to('login')->with('message', 'Please login to edit posts');
}
}
示例14: posts_delete
public function posts_delete()
{
$this->load->library('form_validation');
if ($this->form_validation->run('delete-post') == FALSE) {
redirect($this->session->previous_url, 'refresh');
} else {
$post = Post::find($this->input->post('id'));
Post::destroy($this->input->post('id'));
Comment::where('post_id', $post->id)->delete();
$this->session->set_flashdata('message', 'Successfully deleted <strong>' . $post->title . '</strong>');
redirect('dashboard/posts', 'refresh');
}
}
示例15: destroy
/**
* Remove the specified post from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
Post::destroy($id);
return Redirect::route('admin.posts.index');
}