当前位置: 首页>>代码示例>>PHP>>正文


PHP Post::destroy方法代码示例

本文整理汇总了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());
 }
开发者ID:joeymetal,项目名称:v1,代码行数:8,代码来源:_AkActiveRecord_basic_CRUD.php

示例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');
 }
开发者ID:Kouga-Huang,项目名称:laravel-blog,代码行数:8,代码来源:PostsController.php

示例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);
 }
开发者ID:SafirX,项目名称:gdi-php-mvc,代码行数:37,代码来源:post.php

示例4: eliminar

 public function eliminar($id)
 {
     Post::destroy($id);
 }
开发者ID:fluzo,项目名称:foro,代码行数:4,代码来源:Post.php

示例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());
 }
开发者ID:alchemyphp,项目名称:cms,代码行数:11,代码来源:DatabaseModelTest.php

示例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");
     }
 }
开发者ID:jtaurus,项目名称:jtauri_blog,代码行数:16,代码来源:UserController.php

示例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();
 }
开发者ID:amirmasoud,项目名称:API,代码行数:17,代码来源:PostController.php

示例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');
 }
开发者ID:arbuuuud,项目名称:gnt-aops,代码行数:11,代码来源:PostsController.php

示例9: delete

 /**
  * Remove the specified post from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     Post::destroy($id);
     return Redirect::back();
 }
开发者ID:syafdia,项目名称:PAS,代码行数:11,代码来源:AdminPostsController.php

示例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');
 }
开发者ID:Rwilkins1,项目名称:laravel_blog,代码行数:11,代码来源:PostsController.php

示例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'));
 }
开发者ID:rinodung,项目名称:hello-video-laravel,代码行数:13,代码来源:AdminPostController.php

示例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');
 }
开发者ID:ahoyhoy-sw,项目名称:laravel_workshop_2014,代码行数:13,代码来源:PostsController.php

示例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');
     }
 }
开发者ID:vinamilvinamil,项目名称:chatterr,代码行数:17,代码来源:PostController.php

示例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');
     }
 }
开发者ID:harithaakella,项目名称:my_new_blog,代码行数:13,代码来源:Dashboard.php

示例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');
 }
开发者ID:mldarshana,项目名称:Getting-started-with-Laravel-4,代码行数:11,代码来源:AdminPostsController.php


注:本文中的Post::destroy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。