9 lines
583 B
PHP
9 lines
583 B
PHP
<?php
|
|
namespace App\Models;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
final class DownloadProduct extends Model {
|
|
protected $fillable = ['name','description','version','platform','file_path','original_filename','file_size','download_count','is_published'];
|
|
protected function casts(): array { return ['is_published'=>'boolean','file_size'=>'integer','download_count'=>'integer']; }
|
|
public function getFormattedSizeAttribute(): string { return $this->file_size >= 1048576 ? number_format($this->file_size/1048576,1).' MB' : number_format($this->file_size/1024,1).' KB'; }
|
|
}
|