I am using a Laravel jenssengers MongoDB and it is my first time seeing the word obfuscating. I see many open source options on github but nothing that does what i want.
How do i obfuscate my url from looking like this
To looking like
My routes expect an article id like so
Route::get('/article/{article_id}', [
'uses' => 'MainController@singleArticle',
'as' => 'article'
]);
...And Controller
public function singleArticle($article_id){
$article = Article::find($article_id);
return view('article',['article' => $article]);
}
And i am assuming it is quicker working with ids rather than text.(Correct me if i am wrong) Therefore changing the route to ...
Route::get('/article/{article_title}', [
'uses' => 'MainController@singleArticle',
'as' => 'article'
]);
and controller to
public function singleArticle($article_title){
$article = Article::where('title',$article_title);
return view('article',['article' => $article]);
}
Would be a bad choice that i might regret later when two articles have the same title?
So how do i obfuscate my routes, to look like the title of the article which is being fetched from the database?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire