attributes['file'] = base64_encode($value); } public function getFileAttribute($value) { if (base64_decode($value, true) === false) { $value = base64_encode($value); } return $value; } public function getFile() { $size = $this->size; $units = ['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 ($this->poster == 'ATTACHMENT') { if (mime($this->type) == true) { $var = ''; return '
  • '.$var.'
    '.$this->name.'

    '.$value.'

  • '; } else { //$var = ''; $var = ''.strtoupper($this->type).'
    '.$this->name.'

    '.$value.'

    '; return '
  • '.$var.'
  • '; } } } }