The goals relation is being eager loaded in a separate query so you will not have access to goals.Goal_id
in your main query builder, instead you can modify your with()
clause to pick specific columns from eager loaded relation as with('goals:Goal_id,another_column')
$tests = test::with('goals:Goal_id')
->where('Goal_id', $goal_id)
->select(['test.id as id','test.mode as mode'])
->get();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…