當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Post::delete方法代碼示例

本文整理匯總了PHP中app\Post::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP Post::delete方法的具體用法?PHP Post::delete怎麽用?PHP Post::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Post的用法示例。


在下文中一共展示了Post::delete方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: destroy

 public function destroy(Post $post)
 {
     if ($post->user()->getResults() != Auth::user()) {
         return response('Unauthorized.', 401);
     }
     return view('posts.show', compact($post->delete()));
 }
開發者ID:khaled-barca,項目名稱:MyTunnelVision,代碼行數:7,代碼來源:PostController.php

示例2: destroy

 public function destroy(Post $post)
 {
     if ($post->image && \File::exists(public_path() . "/" . $post->image)) {
         \File::delete(public_path() . "/" . $post->image);
     }
     $post->delete();
     return redirect()->route("backend.post.index");
 }
開發者ID:erayaydin,項目名稱:erayaydin,代碼行數:8,代碼來源:PostController.php

示例3: destroy

 public function destroy(Post $post)
 {
     if (\Request::has('id')) {
         Post::destroy(\Request::input('id'));
         return ['result' => true];
     }
     $post->delete();
     return redirect('dash/post')->with('message', 'Post was delete success.');
 }
開發者ID:Yuth-Set,項目名稱:cms,代碼行數:9,代碼來源:PostController.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|max:90', 'body' => 'required', 'price' => 'required', 'category' => 'required', 'community' => 'required', 'city_id' => 'required']);
     $post = new Post();
     $post->title = $request->title;
     $post->body = $request->body;
     $post->user_id = Auth::user()->id;
     $post->price = $request->price;
     $post->category_id = $request->category;
     $post->community_id = $request->community;
     $post->city_id = $request->city_id;
     $post->save();
     $files = $request->file('filefield');
     $file_count = count($files);
     $uploadcount = 0;
     foreach ($files as $file) {
         // Validate each file
         $rules = array('filefield' => 'required|mimes:png,gif,jpeg');
         //'required|mimes:png,gif,jpeg,txt,pdf,doc'
         $validator = Validator::make(array('filefield' => $file), $rules);
         if ($validator->passes()) {
             $file = $file;
             $name = time() . '-' . $file->getClientOriginalName();
             $upload_success = $file->move(public_path() . '/uploads/', $name);
             $media = new Media();
             $media->name = $name;
             $media->post_id = $post->id;
             $media->save();
             $uploadcount++;
         }
     }
     if ($uploadcount == $file_count) {
         return Redirect('/')->with('message', 'Post created');
     } else {
         $post->delete();
         return Redirect::to('/post/create')->withInput()->withErrors($validator);
     }
 }
開發者ID:jakeboyles,項目名稱:GuyBuy,代碼行數:44,代碼來源:PostController.php

示例5: destroy

 /**
  * Remove the specified post from storage.
  *
  * @param  Post $post
  * @return \Illuminate\Http\JsonResponse
  */
 public function destroy($post)
 {
     $post->delete();
 }
開發者ID:lolzballs,項目名稱:website,代碼行數:10,代碼來源:PostController.php

示例6: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  Post  $post
  * @return Response
  */
 public function destroy(Post $post)
 {
     $post->delete();
     return redirect('posts/postsAuth');
 }
開發者ID:grigoremihaela,項目名稱:myfirstlaravel,代碼行數:11,代碼來源:PostsController.php

示例7: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Post $post)
 {
     $post->delete();
     return redirect()->to('admin');
 }
開發者ID:jeremytubbs-deprecated,項目名稱:L51-Start-Here,代碼行數:11,代碼來源:PostsController.php

示例8: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  \App\Post $post
  * @return Response
  */
 public function destroy(Post $post)
 {
     $post->delete();
     return Redirect::route('superadmin.posts.index')->with('message', 'Post deleted.');
     // show after destroy post
     //return view('posts.show', compact('post'));
 }
開發者ID:JRizzle88,項目名稱:wewillcode,代碼行數:13,代碼來源:PostsController.php

示例9: destroy

 public function destroy(Post $post)
 {
     $post->delete();
     return ['message' => 'Articolo eliminato con successo!'];
 }
開發者ID:bertog,項目名稱:eengineering-web,代碼行數:5,代碼來源:PostsController.php

示例10: destroy

 public function destroy(Post $post)
 {
     if (Storage::disk('portfolio')->exists($post->image) && Storage::disk('portfolioThumb')->exists($post->thumb)) {
         Storage::disk('portfolio')->delete($post->image);
         Storage::disk('portfolioThumb')->delete($post->thumb);
     }
     $post->delete();
     return redirect()->route('post.index')->with('success', 'محصول با موفقیت حذف شد.');
 }
開發者ID:majid-n,項目名稱:cometdev,代碼行數:9,代碼來源:PostController.php

示例11: destroy

 public function destroy(Post $post)
 {
     $post->delete();
     return response(['url' => url('/')]);
 }
開發者ID:enhive,項目名稱:vev,代碼行數:5,代碼來源:PostController.php

示例12: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Post $post)
 {
     $postStatus = $post->delete();
     if ($postStatus) {
         \Session::flash('flash_message_destroyed', 'Tu post ha sido borrado');
         return redirect('posts');
     }
     \Session::flash('flash_message_destroyFailed', 'Tu post no ha podido ser eliminado');
     return redirect('posts');
 }
開發者ID:Zizazao,項目名稱:evolutizalocal,代碼行數:16,代碼來源:indexController.php

示例13: destroy

 public function destroy(Post $post)
 {
     return ['success' => $post->delete()];
 }
開發者ID:net-shell,項目名稱:socialsync,代碼行數:4,代碼來源:PostController.php

示例14: destroy

 public function destroy(Post $post)
 {
     $post->delete();
     \Session::flash('flash-success', '投稿を削除しました。');
     return back();
 }
開發者ID:wakin-,項目名稱:bbs,代碼行數:6,代碼來源:PostController.php

示例15: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param Post $post
  * @return mixed
  */
 public function destroy(Request $request, Post $post)
 {
     $title = $post->post_title;
     Comment::where('post_id', $post->id)->delete();
     $post->delete();
     $request->session()->flash('success', "Deleted '{$title}' successfully");
     return back();
 }
開發者ID:DrizzlyOwl,項目名稱:drizzlyowl.co.uk,代碼行數:15,代碼來源:AdminController.php


注:本文中的app\Post::delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。