Last time I did something similar, I used either a foreach or I constructed a join using the query builder, depending on how important performance was.
@JarekTkaczyk
company has many motortype
and motorparts are specific to motortype
so i want to get company's specific motortype ($this->belongsToMany('MotorType'); )
and its motorpart ( motorpart of motortype's returned by above relation )
same as Has Many Through but it has Many To Many relationship( motorType and MotorParts )
@JarekTkaczyk but wat would be database table structure for tat ?? how should i relate both (company and motorTypes) in MotorParts ?? i should add company_id and motortype_id in motorPart table ??
i tried ur above soln but it gives motorPart of which it doesnt belong to company( It should belong both to company and Motortype)