I have following query which works fine and gives result for StatusType
AddOnModel::with('StatusType')->get();
But when I write below, it does not bind StatusType Records
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();
The part which does not work is this one: ->with('StatusType')
Am I doing something incorrectly?
Here is the Model
class AddOnModel extends Model {
public $table = 'tbladdon';
public $primaryKey = 'AddOnID';
public $timestamps = true;
public function StatusType() {
return $this->hasOne('\StatusTypeModel', 'StatusTypeID', 'StatusTypeID');
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire