2025-07-23 15:41:01 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models\Boards;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2025-08-21 09:50:15 +09:00
|
|
|
use App\Models\Commons\File;
|
2025-07-23 15:41:01 +09:00
|
|
|
|
2025-08-21 09:50:15 +09:00
|
|
|
/**
|
|
|
|
|
* @mixin IdeHelperPost
|
|
|
|
|
*/
|
2025-07-23 15:41:01 +09:00
|
|
|
class Post extends Model
|
|
|
|
|
{
|
|
|
|
|
use SoftDeletes;
|
|
|
|
|
|
|
|
|
|
protected $table = 'posts';
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'tenant_id', 'board_id', 'user_id', 'title', 'content', 'editor_type',
|
|
|
|
|
'ip_address', 'is_notice', 'is_secret', 'views', 'status'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function files() {
|
2025-07-29 13:00:25 +09:00
|
|
|
return $this->morphMany(File::class, 'fileable');
|
2025-07-23 15:41:01 +09:00
|
|
|
}
|
|
|
|
|
public function comments() {
|
|
|
|
|
return $this->hasMany(BoardComment::class, 'post_id')->whereNull('parent_id')->where('status', 'active');
|
|
|
|
|
}
|
|
|
|
|
public function board() {
|
|
|
|
|
return $this->belongsTo(Board::class, 'board_id');
|
|
|
|
|
}
|
|
|
|
|
}
|