Category page and subcategory page
up vote
0
down vote
favorite
guys!
I have navbar with category and subcategory with their subsubcategory.
Now I want to make page for every category and subcategory. So, I have 5 main category and there is subcategory and on.
Every page of category and subcategory has its own information.
I've done this:
Route::get('c/hierarchy', 'CategoryController@index')->where('hierarchy', '(.*)?');
Controller:
public function index($hierarchy)
$categories = explode('/', $hierarchy);
$category = last($categories);
$main = Category::where('slug', $category)->firstOrFail();
reset($categories);
return view('page', compact('main'));
It works but logic seems wrong. Am I using the right way?
laravel
add a comment |
up vote
0
down vote
favorite
guys!
I have navbar with category and subcategory with their subsubcategory.
Now I want to make page for every category and subcategory. So, I have 5 main category and there is subcategory and on.
Every page of category and subcategory has its own information.
I've done this:
Route::get('c/hierarchy', 'CategoryController@index')->where('hierarchy', '(.*)?');
Controller:
public function index($hierarchy)
$categories = explode('/', $hierarchy);
$category = last($categories);
$main = Category::where('slug', $category)->firstOrFail();
reset($categories);
return view('page', compact('main'));
It works but logic seems wrong. Am I using the right way?
laravel
1
Why do you think the logic seems wrong?
– Manpreet
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
guys!
I have navbar with category and subcategory with their subsubcategory.
Now I want to make page for every category and subcategory. So, I have 5 main category and there is subcategory and on.
Every page of category and subcategory has its own information.
I've done this:
Route::get('c/hierarchy', 'CategoryController@index')->where('hierarchy', '(.*)?');
Controller:
public function index($hierarchy)
$categories = explode('/', $hierarchy);
$category = last($categories);
$main = Category::where('slug', $category)->firstOrFail();
reset($categories);
return view('page', compact('main'));
It works but logic seems wrong. Am I using the right way?
laravel
guys!
I have navbar with category and subcategory with their subsubcategory.
Now I want to make page for every category and subcategory. So, I have 5 main category and there is subcategory and on.
Every page of category and subcategory has its own information.
I've done this:
Route::get('c/hierarchy', 'CategoryController@index')->where('hierarchy', '(.*)?');
Controller:
public function index($hierarchy)
$categories = explode('/', $hierarchy);
$category = last($categories);
$main = Category::where('slug', $category)->firstOrFail();
reset($categories);
return view('page', compact('main'));
It works but logic seems wrong. Am I using the right way?
laravel
laravel
asked 2 days ago
Tom West
104
104
1
Why do you think the logic seems wrong?
– Manpreet
2 days ago
add a comment |
1
Why do you think the logic seems wrong?
– Manpreet
2 days ago
1
1
Why do you think the logic seems wrong?
– Manpreet
2 days ago
Why do you think the logic seems wrong?
– Manpreet
2 days ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237757%2fcategory-page-and-subcategory-page%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Why do you think the logic seems wrong?
– Manpreet
2 days ago