【发布时间】:2014-05-13 14:21:17
【问题描述】:
我正在尝试这样做
$this->current_user->company->routes
我希望根据当前登录的用户公司获得路线列表。
这是我得到的错误
Symfony \ Component \ Debug \ Exception \ FatalErrorException
Call to undefined method Illuminate\Support\Facades\Route::newQuery()
我知道我从以下两个方面都得到了正确的信息
$this->current_user
和
$this->current_user->company
这是我的公司模型
<?php
class Company extends Eloquent
{
protected $guarded = array(
'id',
'created_at',
'updated_at',
);
public static function getDropDownArray()
{
$return = array();
$companies = Company::all();
foreach($companies as &$company)
{
$return[$company->id] = $company->title;
}
return $return;
}
public function routes()
{
return $this->hasMany('Route');
}
public function users()
{
return $this->hasMany('User');
}
public function locations()
{
return $this->hasMany('Location');
}
public function publications()
{
return $this->hasMany('Publication');
}
public function racks()
{
return $this->hasMany('Rack');
}
}
【问题讨论】: