Ejemplo n.º 1
0
 /**
  * Include media.
  *
  * @param \Flashtag\Posts\Category $category
  * @return \League\Fractal\Resource\Item
  */
 public function includeMedia(Category $category)
 {
     if (!$category->hasMedia()) {
         return null;
     }
     return $this->item($category->media, new MediaTransformer());
 }
Ejemplo n.º 2
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'));
 }
Ejemplo n.º 3
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'));
 }
Ejemplo n.º 4
0
 public function edit($id)
 {
     $post = Post::with('author', 'fields', 'category', 'tags')->findOrFail($id);
     $post->lock(auth()->user()->id);
     $categories = Category::all(['id', 'name']);
     $tags = Tag::all(['id', 'name']);
     $authors = Author::all(['id', 'name']);
     $fields = Field::all();
     return view('admin::posts.edit', compact('post', 'categories', 'tags', 'authors', 'fields'));
 }
Ejemplo n.º 5
0
 /**
  * @param  int $id
  * @return \Dingo\Api\Http\Response
  */
 public function destroy($id)
 {
     $category = $this->category->findOrFail($id);
     $category->delete();
     return $this->response->item($category, new CategoryTransformer());
 }
Ejemplo n.º 6
0
 /**
  * @param int $id
  */
 public function destroy($id)
 {
     $field = Category::findOrFail($id);
     $field->delete();
 }
Ejemplo n.º 7
0
 /**
  * @param Category $category
  * @param \Illuminate\Http\Request $request
  */
 private function syncTagsFromRequest(Category $category, $request)
 {
     $tags = $request->get('tags', []);
     $category->tags()->sync($tags);
 }
Ejemplo n.º 8
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'));
 }