Skip to content

Commit a46c7d8

Browse files
committedApr 6, 2022
refactor in getting route segments
1 parent c786c6c commit a46c7d8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

‎src/Controllers/BinshopsReaderController.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct()
3535
* @param null $category_slug
3636
* @return mixed
3737
*/
38-
public function index($locale, Request $request, $category_slug = null)
38+
public function index($locale = null, Request $request, $category_slug = null)
3939
{
4040
// the published_at + is_published are handled by BinshopsBlogPublishedScope, and don't take effect if the logged in user can manageb log posts
4141

@@ -126,10 +126,12 @@ public function search(Request $request)
126126
* @param $category_slug
127127
* @return mixed
128128
*/
129-
public function view_category($locale, $hierarchy, Request $request)
129+
public function view_category(Request $request)
130130
{
131+
$hierarchy = $request->route('subcategories');
132+
131133
$categories = explode('/', $hierarchy);
132-
return $this->index($locale, $request, end($categories));
134+
return $this->index($request->get('locale'), $request, end($categories));
133135
}
134136

135137
/**
@@ -139,8 +141,10 @@ public function view_category($locale, $hierarchy, Request $request)
139141
* @param $blogPostSlug
140142
* @return mixed
141143
*/
142-
public function viewSinglePost(Request $request, $locale, $blogPostSlug)
144+
public function viewSinglePost(Request $request)
143145
{
146+
$blogPostSlug = $request->route('blogPostSlug');
147+
144148
// the published_at + is_published are handled by BinshopsBlogPublishedScope, and don't take effect if the logged in user can manage log posts
145149
$blog_post = BinshopsPostTranslation::where([
146150
["slug", "=", $blogPostSlug],

0 commit comments

Comments
 (0)
Failed to load comments.