5

can you help me?

if in laravel we want to get a variable in url so in route we must wrote like this:

Route::get('myweb/article/{article_id}','Controller/ArticleController@show');

it will generate like this

www.myweb.com/article/1

and in controller we can get ID with this:

public static function show(){
   list($article_id) = func_get_args();
}

how about if i want url like this:

www.myweb.com/article-1   // assume 1 is article_id

how i must write line in routes.php? and how to get the ID in controller?

tereško
  • 58,060
  • 25
  • 98
  • 150

1 Answers1

3

Did you try something like this:

Route::get('myweb/article-{article_id}','Controller/ArticleController@show');
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279