Two tables BillDetails and Attachments. Each entry in BillDetails may have multiple attachments. I need to display the BillDetails data with Attachments as link in a gridview. That is the gridview need to have columns Amount, Description and Attachments.
model will check the current record with relation table and display the attachment link
<?php
public function attachmentlink(){
//$this->attachment is a relation name
if($this->attachment){
echo "<ul>";
foreach($this->attachment as $attachment){
echo "<li><a href=".$attachment->path.">".$attachment->name."</a></li>";
}
echo "</ul>";
}else
echo "No Attachments";
}
?>