1
我有以下查询,工作正常,并给出结果为StatusType随着雄辩
AddOnModel::with('StatusType')->get();
但是,当我写的下面,它不绑定StatusType记录
AddOnModel
::select(\DB::Raw('A.AddOnID, A.AddOn, Count(R.AddOnID) as Total'))
->from('tblAddOn as A')
->with('StatusType')
->leftjoin('tblrevenue as R', \DB::raw('R.AddOnID'), '=', \DB::raw('A.AddOnID'))
->groupBy("A.AddOnID", "A.AddOn")->get();
它所做的部分查询问题不工作是这一个:->with('StatusType')
我做错了什么吗?
这里是示范
class AddOnModel extends Model {
public $table = 'tbladdon';
public $primaryKey = 'AddOnID';
public $timestamps = true;
public function StatusType() {
return $this->hasOne('\StatusTypeModel', 'StatusTypeID', 'StatusTypeID');
}
}
还是同样的问题 – Pankaj
好吧,什么是结果(我的意思是任何错误或其他?) –
https://i.stack.imgur.com/Mgh0d.png – Pankaj