public function edit($id) { $post = Post::where('post_type', 'post')->where('id', $id)->first(); if (!isset($post->id)) { $post = new Post(); } return view('user.property-create', compact('post')); }
public function edit($id) { $post = Post::where('post_type', 'post')->where('id', $id)->first(); if (!isset($post->id)) { $post = new Post(); } return view('cms::post.post', compact('post')); }
public function destroy($id) { // remove specific post $post = Post::where('post_type', 'post')->where('id', $id)->first(); // remove all post meta PostMeta::where('post_id', $post->id)->delete(); // remove all post tags PostTag::where('post_id', $post->id)->delete(); if ($post && $post->delete()) { return true; } return false; }
public function handle() { $post = Post::where('slug', $this->slug)->first(); if (!$post) { return redirect()->route('front.error-404'); } $postTagIds = array(); if (count($post->postTags) > 0) { foreach ($post->postTags as $postTag) { $postTagIds[] = $postTag->tag_id; } } // Retrieve related posts by specific tags $relatedPosts = Post::join('post_tags', 'posts.id', '=', 'post_tags.post_id')->join('tags', 'post_tags.tag_id', '=', 'tags.id')->whereIn('post_tags.tag_id', $postTagIds)->orderByRaw('RAND()')->take(10)->select('posts.*', 'tags.name as tagName')->take(3)->distinct()->get(); return view('property', compact('post', 'relatedPosts')); }
public static function userPosts() { return Post::where('post_type', 'post')->where('user_id', Auth::id())->where('is_visible', 1); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $post = Post::where('id', $id)->where('post_type', 'page')->first(); if ($post && $post->delete) { return redirect()->back()->with('message', 'Deleted Successfully.'); } return redirect()->back()->with('message', 'Unable to delete.'); }