Files

72 lines
1.5 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Modules\Auth\Entities\User;
class Document extends Model
{
use HasUuids, SoftDeletes;
public const STORAGE_DISK = 'local';
protected $table = 'documents';
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'documentable_type',
'documentable_id',
'name',
'path',
'file_size',
'mime_type',
'type',
'description',
'uploaded_by',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'name' => 'string',
'path' => 'string',
'file_size' => 'integer',
'mime_type' => 'string',
'type' => 'string',
'description' => 'string',
];
}
public function documentable(): MorphTo
{
return $this->morphTo();
}
public function uploadedBy(): BelongsTo
{
return $this->belongsTo(User::class, 'uploaded_by');
}
}