php - append item id to slug or find by slug in MySQL using Laravel -
php - append item id to slug or find by slug in MySQL using Laravel -
i have uri's contain slug instead of primary key. find corresponding item searching string. (they tv show names pretty much unique)
example:/show/big-bang-theory/episode/01
i homecoming corresponding show
public function getbyslug($slug) { homecoming show::where('slug', '=', $slug)->firstorfail(); }
however there several users on @ laravel suggesting following:
/show/big-bang-theory-123/episode/01
123
item id of show. can do:
return show::find(123);
the question is, impact noticeable between these 2 , there future problems might run into? there maybe other smarter method have slugs in uri?
in fact it's how it. if plan have info 1 table may utilize slug in url /show/big-bang-theory
, see plenty find it.
however if wanted utilize articles other tables, need add together unique part them (for illustration /otherurls/big-bang-theory
) because don't want create search in many tables.
so it's you, prefer not include things don't need in url. if don't need id
, don't utilize it.
php mysql laravel laravel-4
Comments
Post a Comment