I assume from this code that the variable being passed to your view is "games", but your view is trying to read from a variable called "game" - hence the undefined variable error.
Show us the code for your view.
Here is my index.blade.php view: @extends('layout')
@section('content') <div class="page-header"> <h1>All Games <small>Gotta catch 'em all!</small></h1> </div>
<div class="panel panel-default">
<div class="panel-body">
<a href="{{ action('GamesController@create', $game->id) }}" class="btn btn-primary">Create Game</a>
</div>
</div>
@if ($games->isEmpty())
<p>There are no games! :(</p>
@else
<table class="table table-striped">
<thead>
<tr>
<th>Title</th>
<th>Publisher</th>
<th>Complete</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach($games as $game)
<tr>
<td>{{ $game->title }}</td>
<td>{{ $game->publisher }}</td>
<td>{{ $game->complete ? 'Yes' : 'No' }}</td>
<td>
<a href="{{ action('GamesController@edit', $game->id) }}" class="btn btn-default">Edit</a>
<a href="{{ action('GamesController@delete', $game->id) }}" class="btn btn-danger">Delete</a>
</td>
</tr>
@endforeach
</tbody>
</table>
@endif
Thank you I'll be happy to supply any info required just to help understand Laravel
_I discovered something and please forgive me for going around circles. I'm new.
When I configure this Model:
class game extends Eloquent
protected $table = 'games';
I get the undefined variable "game" not found error-- in the index.blade view
When I run without a Model I get class "game" not found--In the GameController.php file
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community