Apply fixes from StyleCI
This commit is contained in:

committed by
StyleCI Bot

parent
857d3004eb
commit
88f3df2180
@@ -4,14 +4,15 @@ namespace App\Model\helpdesk\Ticket;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Ticket_attachments extends Model {
|
||||
|
||||
class Ticket_attachments extends Model
|
||||
{
|
||||
protected $table = 'ticket_attachment';
|
||||
protected $fillable = [
|
||||
'id', 'thread_id', 'name', 'size', 'type', 'file', 'data', 'poster', 'updated_at', 'created_at',
|
||||
];
|
||||
|
||||
public function setFileAttribute($value) {
|
||||
public function setFileAttribute($value)
|
||||
{
|
||||
if ($value) {
|
||||
$this->attributes['file'] = base64_encode($value);
|
||||
} else {
|
||||
@@ -19,42 +20,43 @@ class Ticket_attachments extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
public function getFileAttribute($value) {
|
||||
public function getFileAttribute($value)
|
||||
{
|
||||
$drive = $this->driver;
|
||||
$name = $this->name;
|
||||
$root = $this->path;
|
||||
if (($drive=="database" || !$drive) && $value && base64_decode($value, true) === false) {
|
||||
|
||||
if (($drive == 'database' || !$drive) && $value && base64_decode($value, true) === false) {
|
||||
$value = base64_encode($value);
|
||||
}
|
||||
if($drive && $drive!=="database"){
|
||||
|
||||
if ($drive && $drive !== 'database') {
|
||||
$storage = new \App\FaveoStorage\Controllers\StorageController();
|
||||
$content = $storage->getFile($drive, $name);
|
||||
$value = base64_encode($content);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getFile() {
|
||||
public function getFile()
|
||||
{
|
||||
$size = $this->size;
|
||||
$drive = $this->driver;
|
||||
$name = $this->name;
|
||||
$root = $this->path;
|
||||
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
|
||||
$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];
|
||||
$value = number_format($size / pow(1024, $power), 2, '.', ',').' '.$units[$power];
|
||||
if ($this->poster == 'ATTACHMENT') {
|
||||
if (mime($this->type) == "image") {
|
||||
if (mime($this->type) == 'image') {
|
||||
$var = '<a href="'.\URL::route('image', ['image_id' => $this->id]).'" target="_blank"><img style="max-width:200px;height:133px;" src="data:image/jpg;base64,'.$this->file.'"/></a>';
|
||||
|
||||
$var = '<a href="' . \URL::route('image', array('image_id' => $this->id)) . '" target="_blank"><img style="max-width:200px;height:133px;" src="data:image/jpg;base64,' . $this->file . '"/></a>';
|
||||
return '<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;">' . $this->name . '</b><br/><p>' . $value . '</p></div></li>';
|
||||
return '<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;">'.$this->name.'</b><br/><p>'.$value.'</p></div></li>';
|
||||
} else {
|
||||
//$var = '<a href="' . URL::route('image', array('image_id' => $attachment->id)) . '" target="_blank"><img style="max-width:200px;height:133px;" src="data:'.$attachment->type.';base64,' . base64_encode($data) . '"/></a>';
|
||||
$var = '<a style="max-width:200px;height:133px;color:#666;" href="' . \URL::route('image', array('image_id' => $this->id)) . '" target="_blank"><span class="mailbox-attachment-icon" style="background-color:#fff; font-size:18px;">' . strtoupper(str_limit($this->type,15)) . '</span><div class="mailbox-attachment-info"><span ><b style="word-wrap: break-word;">' . $this->name . '</b><br/><p>' . $value . '</p></span></div></a>';
|
||||
return '<li style="background-color:#f4f4f4;">' . $var . '</li>';
|
||||
$var = '<a style="max-width:200px;height:133px;color:#666;" href="'.\URL::route('image', ['image_id' => $this->id]).'" target="_blank"><span class="mailbox-attachment-icon" style="background-color:#fff; font-size:18px;">'.strtoupper(str_limit($this->type, 15)).'</span><div class="mailbox-attachment-info"><span ><b style="word-wrap: break-word;">'.$this->name.'</b><br/><p>'.$value.'</p></span></div></a>';
|
||||
|
||||
return '<li style="background-color:#f4f4f4;">'.$var.'</li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user