M
M
Muhammad2015-04-05 20:30:09
Laravel
Muhammad, 2015-04-05 20:30:09

Dynamic address in Laravel 4?

Good evening. I am building an online store with Laravel. Implemented categories using nested sets (thanks to Sergey Gladkovsky ). Now there is a need to display products in categories. The categories table has a url field (transliterates names, for example, telephoni). For example, we have a directory with the following structure:

/catalog/
  computers/
    accessories/
      motherboards/
      video-cards/
  phones/
    smartphones/
    babushkofoni/
    accessories/

There are several questions:
1) How to handle requests like:
/catalog/computers/accessories/motherboards
2) How to solve the problem with directories that have the same url (in the example it is accessories )
Any help would be appreciated

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2015-04-05
@muhammad_97

Try it
and in the controller:

Route::get('{catalog}/{otherLinks?}', '[email protected]')->where('otherLinks', '(.*)');
class MainController extends BaseController {

public function getPage($pageLink, $otherLinks = null)
{
if($otherLinks) 
{
$otherLinks = explode('/', $otherLinks);
// твой код
}
}

}

F
FMars, 2015-04-05
@FMars

All your questions come from the fact that you do not understand how routes work.
learn - laravel.com/docs/4.2/routing

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question