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

First go to app/config/app.php and enable error reporting to see what the error is

And since you're using Blade, I'd sugest you change things like

<a href="{{('cats/'.$cat->id.'')}}">← Cancel </a>
// to
<a href="{{ URL::route('cats.show', $cat->id) }}">Cancel</a>
// or
{{ HTML::linkRoute('cats.show', 'Cancel', $cat->id) }}
Last updated 9 years ago.
0

The error is:

ErrorException (E_UNKNOWN)

Trying to get property of non-object (View: cats\app\views\cats\edit.blade.php)
Last updated 9 years ago.
0

I changed it to

<a href="{{ URL::route('cats.show', $cat->id }}">Cancel</a>

Now the error is:

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_PARSE)

syntax error, unexpected ';'
Open: cats\app\storage\views\88e3954eab3748f028fa27b743101f6c 
    <html>
     
    <?php $__env->startSection('header'); ?>
     
     
    <a href="<?php echo URL::route('cats.show', $cat->id; ?>">Cancel</a>
     
     
     
    <h2>

I guess it's the extra ';' that, somehow, is being added after '$cat->id' , or something else.

Last updated 9 years ago.
0

It was missing a parentheses after cat->id, that's the correct:

<a href="{{ URL::route('cats.show', $cat->id) }}">Cancel</a>

But now I get again the initial error:


ErrorException (E_UNKNOWN)

Trying to get property of non-object (View:cats\app\views\cats\edit.blade.php)

0

I changed the CatController.php:

class CatController extends BaseController {
public function edit($id) {   
       $cat = Cat::find($id);
       return View::make('cats.edit')
                    ->with('cat', $cat)
                    ->with('method', 'put');       
    }
}

So the error was that I didn't create a reference to an 'existing' cat, $cat.

Now the error is that I have an Undefined variable(breed_options) in cats\app\views\cats\edit.blade.php:

ErrorException (E_UNKNOWN)

Undefined variable: breed_options (View: cats\app\views\cats\edit.blade.php)
Last updated 9 years ago.
0

I changed the CatController.php to:

class CatController extends BaseController {
public function edit($id) {
        $breeds = Breed::all();
        if (count($breeds) > 0) {
            $breed_options = array_combine($breeds->lists('id'), $breeds->lists('name'));
        } else {
            $breed_options = array(null, 'Unspecified');
        }
        $cat = Cat::find($id);
        return View::make('cats.edit')
                        ->with('cat', $cat)
                        ->with('method', 'put')
                        ->with('breed_options', $breed_options);
    }
}

And it works!!! omg why did they have debugging disabled? It's a great help!

pogachar thank you for your help!

0

Good to see you managed to fix it yourself. I forgot to add the closing brackets in the example. Fixed now.

Look at relationships for cat - breed

0

Sign in to participate in this thread!

Eventy

Your banner here too?

panosss panosss Joined 18 Jan 2015

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.