Problem with relationship hasOneThrough (i guess)

Posted 1 month ago by kwojcik

Hi guys, i have following tables and structure:

table: Product
- id 
- part_no
- flow_id
table: ProductStructure
- id 
- part_no 
- component_part
table: ProductFlow
- flowID 
- strBFlow 
- strTransitionOne

In raw SQL I can get proper result using this query:

select tPP.*, tP.*, tPF.* from Products.tblProductionPlans tPP
left join Products.tblProduct tP on tP.part_no = tPP.part_no
left join Products.tblProductFlow tPF on tPF.flowId = tP.flow_id
where tPP.plan_date = '2019-06-11 14:27:47'
and tPP.category = 'Upstands'

As you can see i get data from ProductFlow using joined table Product. How to do it in Eloquent? I was thinking about hasOne Through but it doesn't work :/ This is my query:

$plan = $productionPlan::with('product','productStructure','flow')->where([
            ['plan_date','=',$planDate],
            ['type','=',$planType]
        ])->get();

I see error message like:

Call to undefined relationship [flow] on model [App\Http\Models\ProductionPlans\ProductionPlan].

Please sign in or create an account to participate in this conversation.