Exemplo n.º 1
0
    public function run()
    {
        Post::create(['title' => 'First blog post', 'slug' => 'first-blog-post', 'content' => '
This is your first ever **blog post**! It might be a good idea to update this post with some more relevant content.

You can edit this content by selecting **Blog** from the administration back-end menu.

*Enjoy the good times!*
            ', 'excerpt' => 'The first ever blog post is here. It might be a good idea to update this post with some more relevant content.', 'published_at' => Carbon::now(), 'published' => true]);
        Category::create(['name' => trans('richlove.blog::lang.categories.uncategorized'), 'slug' => 'uncategorized']);
    }
Exemplo n.º 2
0
 protected function loadPost()
 {
     $slug = $this->property('slug');
     $post = BlogPost::isPublished()->where('slug', $slug)->first();
     /*
      * Add a "url" helper attribute for linking to each category
      */
     if ($post && $post->categories->count()) {
         $post->categories->each(function ($category) {
             $category->setUrl($this->categoryPage, $this->controller);
         });
     }
     return $post;
 }
Exemplo n.º 3
0
 protected function findDuplicatePost($data)
 {
     if ($id = array_get($data, 'id')) {
         return Post::find($id);
     }
     $title = array_get($data, 'title');
     $post = Post::where('title', $title);
     if ($slug = array_get($data, 'slug')) {
         $post->orWhere('slug', $slug);
     }
     return $post->first();
 }
Exemplo n.º 4
0
 public function onRefresh()
 {
     $content = post($this->formField->getName());
     $previewHtml = PostModel::formatHtml($content, true);
     return ['preview' => $previewHtml];
 }
Exemplo n.º 5
0
 protected function listPosts()
 {
     $category = $this->category ? $this->category->id : null;
     /*
      * List all the posts, eager load their categories
      */
     $posts = BlogPost::with('categories')->listFrontEnd(['page' => $this->property('pageNumber'), 'sort' => $this->property('sortOrder'), 'perPage' => $this->property('postsPerPage'), 'category' => $category]);
     /*
      * Add a "url" helper attribute for linking to each post and category
      */
     $posts->each(function ($post) {
         $post->setUrl($this->postPage, $this->controller);
         $post->categories->each(function ($category) {
             $category->setUrl($this->categoryPage, $this->controller);
         });
     });
     return $posts;
 }
Exemplo n.º 6
0
 public function onRefreshPreview()
 {
     $data = post('Post');
     $previewHtml = Post::formatHtml($data['content'], true);
     return ['preview' => $previewHtml];
 }