Example #1
0
 /**
  * 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'));
 }
Example #2
0
 /**
  * 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'));
 }
Example #3
0
 /**
  * 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'));
 }
Example #4
0
 /**
  * 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'));
 }
Example #5
0
 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'));
 }
Example #6
0
 /**
  * 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'));
 }
Example #8
0
 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);
 }
Example #10
0
 /**
  * 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'));
 }
Example #11
0
 public function destroy(PostDestroyRequest $request, $id)
 {
     $post = Post::findOrFail($id);
     $post->delete();
     return redirect()->route('admin::posts.index');
 }
Example #12
0
 /**
  * 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'));
 }
Example #13
0
 /**
  * @param int $id
  */
 public function destroy($id)
 {
     $post = Post::findOrFail($id);
     $post->delete();
 }