php - Right way to build a link in laravel 5.3 -


im trying build dynamic link view page (blade) laravel 5.3.

my approach is:

<a href=" {{ url::to('articles') }}/{{ $article->id}}/edit">edit></a>   

that output right url base url , other slug: http://mydomain/articles/23/edit
"23" article's id.

this works wonder if there cleaner way that?

many thanks

you can use named routes this

// route file url::get('articles/{articleid}/edit', 'articlescontroller@edit')->name('articles.edit');  //your view <a href="{{ url::route('articles.edit', $article->id) }}">edit</a> 

much more cleaner imo


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -