php - Laravel Cannot load Model from Controller
I was looking at this tutorial for laravel 4 by Dayle Rees. I decided to create my own and I encountered a problem with my Controller not finding the model I created for my table database named 'games'. What could be the problem here? Some screenshots below.
Game Modeldoes not belong to the
I assume from your structure that your
Modelis not namespaced, so you have these 2 options:
use Game;as you did for
$data['games'] = \Game::all();
The error tells you search for a class Game in the namespace Games\Controller\Game. But your Model class is not in this namespace.
You can resolve this by add the use at the top of your class: