Support the ongoing development of Laravel.io →
Eloquent Views Blade
Last updated 2 years ago.
0

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.

Last updated 9 years ago.
0

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

@stop

Thank you I'll be happy to supply any info required just to help understand Laravel

0

_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

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

dendic dendic Joined 30 Dec 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.