我的项目是:https://github.com/xsmyqf/startlaravel
当我访问startlaravel/public/cats/create
时
我收到了错误:
ErrorException (E_UNKNOWN)
Trying to get property of non-object
(View: C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\xiestartlaravel\app\views\cats\single.blade.php)
Open: C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\xiestartlaravel\vendor\laravel\framework\src\Illuminate\View\Engines\PhpEngine.php
// an exception is thrown. This prevents any partial views from leaking.
try
{
include $__path;
}
catch (\Exception $e)
{
$this->handleViewException($e);
}
答案 0 :(得分:0)
我已经纠正了错误,这是因为两条路线对于无法识别的laravel是相同的。 Route :: get(' cats / {id}',function($ id){$ cat = Cat :: find($ id); return View :: make(' cats.single& #39;) - > with(' cat',$ cat);}); Route :: get(' cats / create',function(){$ cat = new Cat;返回View :: make(' cats.edit') - > with(&# 39; cat',$ cat) - > with(' method',' post');});