Reputation: 117
this is Area class function
public function findLatestReport()
{
$getReport = Report::get()->filter('AreaID',$this->ID)
->sort('Date ASC')->first();
return $getReport;
}
This is Report class function
public function getWeatherStatus()
{
return $this->Fields()->filter('Name', 'Weather Status')->first();
}
is there any way to display 'area' template of WeatherStatus details.??
<% loop $findLatestReport %>
{$WeatherStatus}
<% end_loop %>
Upvotes: 1
Views: 42
Reputation: 161
You'll need to use with
, rather than loop
, as you're returning a single DataObject (with ->first()
) rather than a list. Then you should be able to access $WeatherStatus
:
<% with $findLatestReport %>
{$WeatherStatus}
<% end_with %>
Upvotes: 5