39 lines
1018 B
PHP
39 lines
1018 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Database\Factories\ProjectFileFactory;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
|
|
class ProjectFile extends Model
|
|
{
|
|
/** @use HasFactory<ProjectFileFactory> */
|
|
use HasFactory;
|
|
|
|
/** @var list<string> */
|
|
public const EXTENSIONS = ['stl', '3mf', 'gcode'];
|
|
|
|
protected $fillable = [
|
|
'revision_id', 'role', 'original_filename', 'storage_key', 'extension',
|
|
'media_type', 'byte_size', 'sha256', 'uploaded_by', 'printer_profile', 'material',
|
|
];
|
|
|
|
public function revision(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ProjectRevision::class, 'revision_id');
|
|
}
|
|
|
|
public function uploader(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'uploaded_by');
|
|
}
|
|
|
|
public function render(): HasOne
|
|
{
|
|
return $this->hasOne(ProjectFileRender::class);
|
|
}
|
|
}
|