75 lines
1.7 KiB
PHP
75 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property int|null $thread_id
|
|
* @property int|null $post_id
|
|
* @property int|null $attachment_extension_id
|
|
* @property int|null $attachment_group_id
|
|
* @property int|null $user_id
|
|
* @property string $disk
|
|
* @property string $path
|
|
* @property string $original_name
|
|
* @property string|null $extension
|
|
* @property string $mime_type
|
|
* @property int $size_bytes
|
|
* @mixin \Eloquent
|
|
*/
|
|
class Attachment extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'thread_id',
|
|
'post_id',
|
|
'attachment_extension_id',
|
|
'attachment_group_id',
|
|
'user_id',
|
|
'disk',
|
|
'path',
|
|
'thumbnail_path',
|
|
'thumbnail_mime_type',
|
|
'thumbnail_size_bytes',
|
|
'original_name',
|
|
'extension',
|
|
'mime_type',
|
|
'size_bytes',
|
|
];
|
|
|
|
protected $casts = [
|
|
'size_bytes' => 'int',
|
|
'thumbnail_size_bytes' => 'int',
|
|
];
|
|
|
|
public function thread(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Thread::class);
|
|
}
|
|
|
|
public function post(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Post::class);
|
|
}
|
|
|
|
public function extension(): BelongsTo
|
|
{
|
|
return $this->belongsTo(AttachmentExtension::class, 'attachment_extension_id');
|
|
}
|
|
|
|
public function group(): BelongsTo
|
|
{
|
|
return $this->belongsTo(AttachmentGroup::class, 'attachment_group_id');
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
}
|