While processing we may need to render some data such as 0,1 or so on. Male is 0 and Female is 1 => which is usually complex to read for project list display so CSS code to display with color is used.
Following code for Gender Status is written inside Model
public function getGender()
{
if($this->gender == 0){
return "<span class='label label-info'> Male </span>";
}elseif($this->gender == 1){
return "<span class='label label-success'> Female </span>";
}
elseif($this->gender == 2){
return "<span class='label label-warning'> Other </span>";
}
else{
return "<span class='label label-danger'> ERROR EXIST </span>";
}
}
To call the function written inside Model we must use any retrieved instantiate of that model inside HTML rendering {!! ………… !!}
{!!$testimonial->getStatus()!!}
Following code is for whole 5 status
public function getPatientVisitedOrNotVisitedStatus(){
$status = $this->status;
if($status ==0)
{
return '<span class="label label-danger"> '."NOT VISITED YET".' </span>';
}
else if($status ==1)
{
return '<span class="label label-info"> '."FIRST VISIT - Normal Checkup".' </span>';
}
else if ($status ==2)
{
return '<span class="label label-warning"> '."Followed Up".' </span>';
}
else if ($status ==3)
{
return '<span style="background-color:lightblue" > '."Report Pending".' </span>';
}
else if ($status ==4)
{
return '<span class="label label-success"> '."Admitted".' </span>';
}
else if ($status ==5)
{
return '<span style="background-color:pink"> '."Discharge".' </span>';
}
}