/**
  * function to load data.
  *
  * @param type $id
  *
  * @return type file
  */
 public function get_data($id)
 {
     $attachments = Attachment::where('id', '=', $id)->get();
     foreach ($attachments as $attachment) {
         header('Content-type: application/' . $attachment->type . '');
         header('Content-Disposition: inline; filename=' . $attachment->name . '');
         header('Content-Transfer-Encoding: binary');
         echo $attachment->file;
     }
 }
}
$body = App\Http\Controllers\MailController::trimInjections($body);
//dd($body);
require_once base_path("vendor/htmlpurifier/library/HTMLPurifier.auto.php");
$config = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($config);
$body = $purifier->purify($body);
//dd($config);
?>
            {!! $body !!}    
        </div>
        <div class="box-footer">

            <ul class='mailbox-attachments clearfix'>
                <?php 
$attachments = \App\Attcahment::where('thread_id', '=', $thread->id)->get();
foreach ($attachments as $attachment) {
    $size = $attachment->size;
    $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
    $power = $size > 0 ? floor(log($size, 1024)) : 0;
    $value = number_format($size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power];
    if ($attachment->poster == 'ATTACHMENT') {
        if ($attachment->type == 'jpg' || $attachment->type == 'JPG' || $attachment->type == 'jpeg' || $attachment->type == 'JPEG' || $attachment->type == 'png' || $attachment->type == 'PNG' || $attachment->type == 'gif' || $attachment->type == 'GIF') {
            $image = @imagecreatefromstring($attachment->file);
            ob_start();
            imagejpeg($image, null, 80);
            $data = ob_get_contents();
            ob_end_clean();
            $var = '<a href="' . URL::route('image', array('image_id' => $attachment->id)) . '" target="_blank"><img style="max-width:200px;height:133px;" src="data:image/jpg;base64,' . base64_encode($data) . '"/></a>';
            echo '<li style="background-color:#f4f4f4;"><span class="mailbox-attachment-icon has-img">' . $var . '</span><div class="mailbox-attachment-info"><b style="word-wrap: break-word;">' . $attachment->name . '</b><br/><p>' . $value . '</p></div></li>';
        } else {