Skip to content

Commit 29fd534

Browse files
committed
blog post categories
1 parent fd8cd7c commit 29fd534

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/Controllers/BinshopsReaderController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,19 @@ public function viewSinglePost(Request $request, $locale, $blogPostSlug)
151151
$captcha->runCaptchaBeforeShowingPosts($request, $blog_post);
152152
}
153153

154+
$categories = $blog_post->post->categories()->with([ 'categoryTranslations' => function($query) use ($request){
155+
$query->where("lang_id" , '=' , $request->get("lang_id"));
156+
}
157+
])->get();
154158
return view("binshopsblog::single_post", [
155159
'post' => $blog_post,
156160
// the default scope only selects approved comments, ordered by id
157161
'comments' => $blog_post->post->comments()
158162
->with("user")
159163
->get(),
160164
'captcha' => $captcha,
165+
'categories' => $categories,
166+
'locale' => $request->get("locale")
161167
]);
162168
}
163169

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class=''>
2-
@foreach($post->categories as $category)
3-
<a class='btn btn-outline-secondary btn-sm m-1' href='{{$category->url()}}'>
4-
{{$category->category_name}}
5-
</a>
6-
@endforeach
7-
</div>
2+
@foreach($categories as $category)
3+
<a class='btn btn-outline-secondary btn-sm m-1' href='{{$category->categoryTranslations[0]->url($locale)}}'>
4+
{{$category->categoryTranslations[0]->category_name}}
5+
</a>
6+
@endforeach
7+
</div>

src/Views/binshopsblog/partials/full_post_details.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
Posted <strong>{{$post->post->posted_at->diffForHumans()}}</strong>
2727

2828
@includeWhen($post->author,"binshopsblog::partials.author",['post'=>$post])
29-
@includeWhen($post->categories,"binshopsblog::partials.categories",['post'=>$post])
29+
@includeWhen($categories,"binshopsblog::partials.categories",['categories'=>$categories])

0 commit comments

Comments
 (0)