/** * Display the specified resource. * * @param string $category_slug * @return \Illuminate\Http\Response */ public function show($category_slug) { $category = Category::getBySlug($category_slug); $posts = Post::whereHas('category', function ($query) use($category_slug) { $query->where('slug', $category_slug); })->simplePaginate(); return view('flashtag::categories.show', compact('category', 'posts')); }
/** * Display the specified resource. * * @param string $tag_slug * @return \Illuminate\Http\Response */ public function show($tag_slug) { $tag = Tag::getBySlug($tag_slug); $posts = Post::whereHas('tags', function ($query) use($tag_slug) { $query->where('slug', $tag_slug); })->simplePaginate(10); return view('flashtag::tags.show', compact('tag', 'posts')); }
/** * Display the specified resource. * * @param string $author_slug * @return \Illuminate\Http\Response */ public function show($author_slug) { $author = Author::getBySlug($author_slug); $posts = Post::whereHas('author', function ($query) use($author_slug) { $query->where('slug', $author_slug)->where('show_author', true); })->simplePaginate(); return view('flashtag::authors.show', compact('author', 'posts')); }
/** * Display the specified resource. * * @param string $post_slug * @return \Illuminate\Http\Response */ public function show($post_slug) { try { $post = Post::showing()->whereSlug($post_slug)->firstOrFail(); } catch (\Exception $e) { abort(404); } $post->viewed(); return view('flashtag::posts.show', compact('post')); }
public function home() { $mostViewed = Post::mostViewed(5)->get(); $leastViewed = Post::leastViewed(5)->get(); $postCount = Post::count(); $categoryCount = Category::count(); $tagCount = Tag::count(); $pageCount = Page::count(); return view('admin::home', compact('mostViewed', 'leastViewed', 'mostViews', 'leastViews', 'postCount', 'categoryCount', 'tagCount', 'pageCount')); }
/** * TODO: We really need ot look at rethinking the way we do the image/media stuff * * @param string $image */ public function destroy($image) { if (str_contains($image, '__cover__')) { $type = explode('-', $image)[0]; $typeClass = '\\Flashtag\\Posts\\' . ucfirst($type); $model = $typeClass::where('cover_image', $image)->first(); $model->update(['cover_image' => null]); } elseif (substr($image, 0, 5) === "post-") { $post = Post::where('image', $image)->first(); $post->update(['image' => null]); } else { $media = Media::where('url', $image)->first(); $media->delete(); } Storage::delete('/public/images/media/' . $image); }
public function index($post_id) { $post = Post::with('revisions')->findOrfail($post_id); return view('admin::posts.revisions.index', compact('post')); }
public function deleteImage(Request $request, $id) { $post = $this->post->findOrFail($id); $post->removeImage(); return $this->response->item($post, new PostTransformer()); }
public function index($post_id) { $post = Post::with('revisions')->findOrfail($post_id); return response()->json($post); }
/** * Display the search result page. * * @param \Illuminate\Http\Request $request * @return \Illuminate\View\View */ public function search(Request $request) { $query = $request->get('q', false); $posts = $query ? Post::showing()->search($query)->get() : collect([]); return view('flashtag::search', compact('posts', 'query')); }
public function destroy(PostDestroyRequest $request, $id) { $post = Post::findOrFail($id); $post->delete(); return redirect()->route('admin::posts.index'); }
/** * Display the default page. * * @return \Illuminate\Http\Response */ public function index() { $posts = Post::getLatest(10); $categories = Category::all(); return view('flashtag::home', compact('posts', 'categories')); }
/** * @param int $id */ public function destroy($id) { $post = Post::findOrFail($id); $post->delete(); }