45 lines
914 B
PHP
45 lines
914 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class PrintPluginVersion extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'plugin_id',
|
|
'version',
|
|
'download_url',
|
|
'md5',
|
|
'file_size',
|
|
'changelog',
|
|
'min_erp_version',
|
|
'published_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'file_size' => 'integer',
|
|
'published_at' => 'datetime',
|
|
];
|
|
|
|
public function plugin(): BelongsTo
|
|
{
|
|
return $this->belongsTo(PrintPlugin::class, 'plugin_id');
|
|
}
|
|
|
|
/**
|
|
* 检查文件完整性
|
|
*/
|
|
public function verifyFile(string $filePath): bool
|
|
{
|
|
if (!file_exists($filePath)) {
|
|
return false;
|
|
}
|
|
return md5_file($filePath) === $this->md5;
|
|
}
|
|
}
|