*EDIT/UPDATE*
I found a solution but don't really know why this has to be. If anyone could answer why this is that would be great.
I found that the MediaFloorplan would show up in my data when I added "floorplan_id" to my field list for MoveInHome being that MoveInHome hasMany Floorplan. Strange because "id" is found within the fields for the contained "Floorplan"
*END EDIT/UPDATE*
I'm working on a project for a home builder and am having a problem getting some data via containable.
App model has this:
public $actsAs = array("Containable");
I'm making a call from FloorplansController to MoveInHome model
$this->loadModel("MoveInHome");
$moveInReadyData = $this->MoveInHome->getByCommunity($communityid,4);
MoveInHome belongsTo Floorplan
Floorplan hasMany MediaFloorplan
Here's the function in the model:
public function getByCommunity($id,$limit=4) {
$params = array(
"fields" => array(
"address",
"city",
"state",
),
"conditions" => array(
"MoveInHome.community_id" => $id,
"MoveInHome.active" => 1,
"MoveInHome.sold" => 0
),
"limit" => $limit,
"order" => "RAND()",
"contain" => array(
"MediaMoveInHome" => array(
"order" => array(
"featured" => "DESC"
),
"fields" => array(
"media_move_in_home_file_path",
),
"limit" => 1,
),
"Floorplan" => array(
"fields" => array(
"id",
"name",
"style",
"bedrooms",
"bathrooms",
"sf_bsmt",
"sf_1flr",
"sf_2flr"
),
"MediaFloorplan" => array(
"conditions" => array(
"MediaFloorplan.type" => "main",
),
"fields" => array(
"id",
"media_floorplan_file_path"
)
)
)
)
);
return $this->find("all", $params);
}
All of the data comes back fine except for that MediaFloorplan doesn't come back at all. Note that I've made a similar contain request in other areas of the site. Would the problem stem from making the request from the FloorplansController to MoveInReady and trying to contain Floorplan, etc?
Thanks for the help.