當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。