Skip to content

Commit fd8cd7c

Browse files
committed
Merge branch 'master' into develop
2 parents b00d57c + f8cb323 commit fd8cd7c

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Laravel Blog
22
Have you worked with Wordpress? Developers call this package wordpress-like laravel blog.
33

4-
### Contact us for any customization:
5-
4+
## Give our package a Star to support us :star: :heart_eyes:
5+
## [Installation Video - Less than 5 Minutes](https://youtu.be/N9NpFUqbftA)
6+
[![Laravel Blog Package](http://img.youtube.com/vi/N9NpFUqbftA/0.jpg)](https://youtu.be/N9NpFUqbftA)
67

78
### Lightweight and Comprehensive
89

src/Controllers/BinshopsCategoryAdminController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ public function update_category(UpdateBinshopsBlogCategoryRequest $request, $cat
167167
)->first();
168168
$category->fill($request->all());
169169
$translation->fill($request->all());
170+
171+
// if the parent_id is passed in as 0 it will create an error
172+
if ($category->parent_id <= 0) {
173+
$category->parent_id = null;
174+
}
175+
170176
$category->save();
171177
$translation->save();
172178

src/Controllers/BinshopsReaderController.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,18 @@ public function index($locale, Request $request, $category_slug = null)
4747
if ($category_slug) {
4848
$category = BinshopsCategoryTranslation::where("slug", $category_slug)->with('category')->firstOrFail()->category;
4949
$categoryChain = $category->getAncestorsAndSelf();
50-
$posts_1 = $category->posts()->where("binshops_post_categories.category_id", $category->id)->with([ 'postTranslations' => function($query) use ($request){
50+
$posts = $category->posts()->where("binshops_post_categories.category_id", $category->id)->with([ 'postTranslations' => function($query) use ($request){
5151
$query->where("lang_id" , '=' , $request->get("lang_id"));
5252
}
53-
])->paginate(config("binshopsblog.per_page", 10));
53+
])->get();
5454

55-
foreach ($posts_1 as $post) {
56-
$trans = $post->postTranslations[0];
57-
$trans->post = $post;
58-
array_push($posts, $trans);
59-
}
55+
$posts = BinshopsPostTranslation::join('binshops_posts', 'binshops_post_translations.post_id', '=', 'binshops_posts.id')
56+
->where('lang_id', $request->get("lang_id"))
57+
->where("is_published" , '=' , true)
58+
->where('posted_at', '<', Carbon::now()->format('Y-m-d H:i:s'))
59+
->orderBy("posted_at", "desc")
60+
->whereIn('binshops_posts.id', $posts->pluck('id'))
61+
->paginate(config("binshopsblog.per_page", 10));
6062

6163
// at the moment we handle this special case (viewing a category) by hard coding in the following two lines.
6264
// You can easily override this in the view files.

0 commit comments

Comments
 (0)