我网站的用户模型如下所示
class User extends Eloquent implements UserInterface, RemindableInterface {
use UserTrait, RemindableTrait;
protected $table = 'users';
protected $hidden = array('password', 'remember_token');
public function answer(){
return $this->hasMany('Answer','user_id');
}
public function supplierranking(){
return $this->hasMany('Supplierrank','userid','id');
}
}
现在每个用户都会在一个看起来像这样的排名模型中对一家公司进行排名
Class Supplierrank extends Eloquent{
public function supplier(){
return $this->belongsTo('Supplier','supplierid','id');
}
public function user(){
return $this->belongsTo('User','userid','id');
}
}
我可以让用户获得排名详细信息,但我还必须获得从供应商表中排名的公司的详细信息
看起来像这样
Class Supplier extends Eloquent{
public function supplierranks(){
return $this->hasMany('Supplierrank','supplierid');
}
}
我所做的查询看起来像这样
$usersandranking = User::where('event','=',$exceleve)->with('supplierranking')->orderBy('id')->get();
它让我得到用户详细信息和排名,但不是供应商名称
谁可以帮我这个事