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) }}
The error is:
ErrorException (E_UNKNOWN)
Trying to get property of non-object (View: cats\app\views\cats\edit.blade.php)
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.
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)
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)
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!
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
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community