我的 UserController 包括以下内容:
public function doaction($domain, $some_id)
{
$user = User::find(Sentry::getUser()->id);
$user->doactions()->attach($some_id);
$response = array('message' => 'doactioned', 'url' => 'http://'.$domain.'.'.Config::get('database.domain').'/undoaction/'.$some_id);
return Response::json($response);
}
我的 routes.php 还包括以下行:
Route::get('/{name}/doaction/{some_id}', array('as' => 'doaction', 'uses' => 'UserController@doaction'));
我试图称这个前端为前端:
<a href="{{URL::route('doaction', array('domain' => $blog->name, 'id' => $blog->id))}}" class="tumblerclone-btn"> <i class="glyphicon glyphicon-plus"></i> Do action here </a>
一旦按下(正确回显 URL),它就会导致我出错:
Symfony \ Component \ Debug \ Exception \ FatalErrorException 在非对象上调用成员函数doactions()
错误的突出显示的代码部分是:
public function doaction($domain, $some_id)
{
$user = User::find(Sentry::getUser()->id);
$user->doactions()->attach($some_id);
$response = array('message' => 'doactioned', 'url' => 'http://'.$domain.'.'.Config::get('database.domain').'/undoaction/'.$some_id);
return Response::json($response);
}
任何想法都提前表示赞赏。