当前位置: 首页>>代码示例>>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;未经允许,请勿转载。