2014-04-19から1日間の記事一覧
Controllerのshowのidに数字が来たら普通にfind、文字列が来たらwhereにする。 public function show($id) { if (is_numeric($id)) { $tag = Tag::find($id); } else { $tag = Tag::where('name', '=', $id)->first(); } }
Controllerのshowのidに数字が来たら普通にfind、文字列が来たらwhereにする。 public function show($id) { if (is_numeric($id)) { $tag = Tag::find($id); } else { $tag = Tag::where('name', '=', $id)->first(); } }