feat(attachments): create Attachment model and migration for file attachments

This commit is contained in:
2026-06-25 12:07:52 -03:00
parent 492c6c4ac2
commit b874a45724
3 changed files with 83 additions and 1 deletions

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Domains\Attachable\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
#[Fillable([
'attachable_type',
'attachable_id',
'path',
'filename',
'type',
'mime_type',
'is_public',
'extension',
'size',
])]
class Attachment extends Model
{
use HasFactory;
protected $table = 'attachments';
protected function casts(): array
{
return [
'attachable_id' => 'integer',
'is_public' => 'boolean',
'size' => 'integer',
];
}
/**
* @return MorphTo<Model, $this>
*/
public function attachable(): MorphTo
{
return $this->morphTo();
}
}