【问题标题】:an error in the cat example in the book of getting started with laravel 4laravel 4入门书中cat示例中的一个错误
【发布时间】:2014-10-30 01:34:47
【问题描述】:

我的项目是: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);
}

【问题讨论】:

  • 它说 $this->handleViewException($e);是一个错误
  • 不,它表示您正在尝试获取非对象的属性。显示你的看法。
  • 我已经更正了错误,是因为这两个路由与laravel相同,无法识别。 Route::get('cats/{id}', function($id) { $cat = Cat::find($id); return View::make('cats.single') ->with('cat' , $cat); }); Route::get('cats/create', function() { $cat = new Cat; return View::make('cats.edit') ->with('cat', $cat) ->with('method ', '发布'); });
  • @JarekTkaczyk 非常感谢。

标签: php laravel blade laravel-routing


【解决方案1】:

我已经更正了错误,是因为两条路由到laravel是一样的,所以无法识别。 Route::get('cats/{id}', function($id) { $cat = Cat::find($id); return View::make('cats.single') ->with('cat' , $cat); }); Route::get('cats/create', function() { $cat = new Cat; return View::make('cats.edit') ->with('cat', $cat) ->with('method ', '发布'); });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-24
    • 1970-01-01
    • 2016-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-01
    • 2014-12-16
    相关资源
    最近更新 更多