| 1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Casts\Attribute;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- class File extends Model
- {
- protected $fillable = [
- 'user_id',
- 'original_name',
- 'mime_type',
- 'path',
- 'link',
- ];
- protected $appends = [
- 'name',
- ];
- public function user(): BelongsTo
- {
- return $this->belongsTo(User::class);
- }
- public function name(): Attribute
- {
- return Attribute::make(
- get: fn () => $this->original_name ?? '',
- );
- }
- }
|