Display All Model Data In Yii With Its Related Table

Hi,

I have two Model:

Employee

Id, FName, LName , Address

Department

Id, name, location

So I would like to display in a print view all Departments with their employee

If a department has 10 employee it should display all if not department will display null

Thanks

It looks like you’re missing the relationship between employees and departments. If an employe BELONGS_TO a department it should have department_id as a foreign key to the departments table. Then a department HAS_MANY employees. Fix your tables and models first, then the list view should retrieve the department WITH its employees.