Beispiel #1
0
 /**
  * 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);
 }
Beispiel #2
0
 /**
  * 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);
     }
 }
Beispiel #4
0
 public function show($slug)
 {
     $post = $this->post->findBySlug($slug);
     return view('blog.show', compact('post'));
 }
Beispiel #5
0
 /**
  * Get the next post of the current post
  * @return object
  */
 public function next()
 {
     return $this->post->getNextOf($this->entity);
 }
Beispiel #6
0
 /**
  * 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)];
 }
Beispiel #7
0
 /**
  * Get the widget data to send to the view
  * @return string
  */
 protected function data()
 {
     return ['posts' => $this->post->all()];
 }
Beispiel #8
0
 public function compose(View $view)
 {
     $limit = $this->setting->get('blog::latest-posts-amount', locale(), 5);
     $view->with('latestPosts', $this->post->latest($limit));
 }
Beispiel #9
0
 /**
  * Get the widget data to send to the view
  * @return string
  */
 protected function data()
 {
     return ['postCount' => $this->post->all()->count()];
 }