Laravel get url per line

Could you help me?

If in laravel we want to get a variable in url, so in the way we have to write like this:

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

he will generate like this

 www.myweb.com/article/1 

and in the controller we can get an identifier 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 should i write a line in routes.php? and how to get the identifier in the controller?

+5
source share
1 answer

You tried something like this:

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

Source: https://habr.com/ru/post/1245851/


All Articles