0

Am trying to return related data but it fails

SO in my controller i have

 $query = EmployeeTasks::with('employee')->find()->all();

return ["data"=>$query]

IN my EmployeeTasks i have the details relationship like

    public function getEmployee()
      {
       return $this->hasOne(CasualEmployees::className(), ['id' => 'employee_id']);
     }

But the data returned doesnt have the employee data even though there should be

Where am i going wrong?

Dumpo of $query has

[{name:'paint', created_at:1532508029....}] it doesnt have employee
2
  • please attach dump of $query Commented Jul 25, 2018 at 17:00
  • @bxN5 ive attached the same Commented Jul 25, 2018 at 17:08

1 Answer 1

1

Try to use asArray():

$data = EmployeeTasks::find()->with('employee')->asArray()->all();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.