I have 2 tables: projects, project_types.
The relations are as follow:
Project => belong to => ProjectType
ProjectType => hasMany => Project
The columns are as follow
Project => id, project_type_id, name, description
ProjectType => id, name
How can I create a virtual field called projectTypeName with the name from projectType based on project_type_id and for those that project_type_id = 0, it will be ""
I have this
public $virtualFields = array(
'projectTypeName' => "IF(Project.project_type_id = 9, 'sales', '')"
);
it correctly shows as "sales" but I don't want to specify it one by one.
Thank you