本文整理汇总了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()));
}
示例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");
}
示例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.');
}
示例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);
}
}
示例5: destroy
/**
* Remove the specified post from storage.
*
* @param Post $post
* @return \Illuminate\Http\JsonResponse
*/
public function destroy($post)
{
$post->delete();
}
示例6: destroy
/**
* Remove the specified resource from storage.
*
* @param Post $post
* @return Response
*/
public function destroy(Post $post)
{
$post->delete();
return redirect('posts/postsAuth');
}
示例7: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy(Post $post)
{
$post->delete();
return redirect()->to('admin');
}
示例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'));
}
示例9: destroy
public function destroy(Post $post)
{
$post->delete();
return ['message' => 'Articolo eliminato con successo!'];
}
示例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', 'محصول با موفقیت حذف شد.');
}
示例11: destroy
public function destroy(Post $post)
{
$post->delete();
return response(['url' => url('/')]);
}
示例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');
}
示例13: destroy
public function destroy(Post $post)
{
return ['success' => $post->delete()];
}
示例14: destroy
public function destroy(Post $post)
{
$post->delete();
\Session::flash('flash-success', '投稿を削除しました。');
return back();
}
示例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();
}