mardi 4 avril 2017

Laravel do not show me the correct date on the page

I'm trying with laravel 5.3 to create a url like, however, does not show me the correct data

localhost/game/ID-NameGame-Console

I have tried:

public function getGame($slug) {
  $game             = \DB::table('games')->first();
  $info_game = \DB::table('info_games')->where('id_game', '=', $game->id_game)->first();
  $console      = \DB::table('console')->where('id', '=', $info_game->id_console)->first();
  $slug             = $game->id.'-'.$game->slug.'-'.$console->abb_cat;
  return view('front.pages.game', compact('game','info_game','console'));
}

The database table is composed in:

game
*----------------*
id |  slug 
1  | the-order
5  | uncharted
*----------------*

info_game
*-------------------------*
id | console_id | id_games
1  |      2     | 5
*-------------------------*

And so the url become:

localhost/game/5-uncharted-ps4

because console_id 2 = ps4

He shows me the page, however, shows me the game data with ID 1 namely The Order and not Uncharted



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire