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?

1 Answer 1

3

Did you try something like this:

Route::get('myweb/article-{article_id}','Controller/ArticleController@show');
Sign up to request clarification or add additional context in comments.

2 Comments

thanks sir !!, im new in laravel so i choose to asking someone first. its awesome. nice job sir.
oh sure, i did it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.