/** * Helper method to create a blog post * @return object */ public function createBlogPost() { $faker = Factory::create(); $title = implode(' ', $faker->words(3)); $slug = Str::slug($title); $data = ['en' => ['title' => $title, 'slug' => $slug, 'content' => $faker->paragraph()], 'fr' => ['title' => $title, 'slug' => $slug, 'content' => $faker->paragraph()], 'category_id' => 1]; return $this->post->create($data); }
/** * Remove the specified resource from storage. * * @param Post $post * @return \Illuminate\Http\RedirectResponse */ public function destroy(Post $post) { $post->tags()->detach(); $this->post->destroy($post); flash(trans('blog::messages.post deleted')); return redirect()->route('admin.blog.post.index'); }
/** * */ private function emptyBlogTables() { foreach ($this->post->all() as $post) { $this->post->destroy($post); } foreach ($this->category->all() as $category) { $this->category->destroy($category); } foreach ($this->tag->all() as $tag) { $this->tag->destroy($tag); } }
public function show($slug) { $post = $this->post->findBySlug($slug); return view('blog.show', compact('post')); }
/** * Get the next post of the current post * @return object */ public function next() { return $this->post->getNextOf($this->entity); }
/** * Get the widget data to send to the view * @return string */ protected function data() { $limit = $this->setting->get('blog::latest-posts-amount', locale(), 5); return ['posts' => $this->post->latest($limit)]; }
/** * Get the widget data to send to the view * @return string */ protected function data() { return ['posts' => $this->post->all()]; }
public function compose(View $view) { $limit = $this->setting->get('blog::latest-posts-amount', locale(), 5); $view->with('latestPosts', $this->post->latest($limit)); }
/** * Get the widget data to send to the view * @return string */ protected function data() { return ['postCount' => $this->post->all()->count()]; }