K
K
Konstantin B.2016-12-05 20:39:56
Laravel
Konstantin B., 2016-12-05 20:39:56

How to transfer this route to laravel?

The Klein router uses this
pattern $route->respond('GET', '/[*:path]/[*:name]/[200x150|600x450|1200x900:size]');
How can you implement something similar in Laravel without creating a bunch of routes with different size parameters, and the $path variable could contain segments with a slash (example: /images/122/122)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrzej Wielski, 2016-12-06
@Kostik_1993

Route::get('/{path}/{name}/{size}', function($path, $name, $size){
    echo implode('/', [$path, $name, $size]);
  })->where([
    'path' => '(.*)',
    'size' => '(200x150|600x450|1200x900)'
  ]);

A
Alexander Aksentiev, 2016-12-05
@Sanasol

https://laravel.com/docs/5.3/routing#parameters-re...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question