- File 모델 추가 (Polymorphic 관계) - Post 모델에 files() MorphMany 관계 추가 - PostService 파일 업로드/삭제/다운로드 메서드 추가 - PostController 파일 관련 액션 추가 - 게시글 작성/수정 폼에 드래그앤드롭 파일 업로드 UI - 게시글 상세에 첨부파일 목록 표시 - tenant 디스크 설정 (공유 스토리지) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
165 lines
7.6 KiB
PHP
165 lines
7.6 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('title', $post->title)
|
|
|
|
@section('content')
|
|
<!-- 페이지 헤더 -->
|
|
<div class="flex justify-between items-center mb-6">
|
|
<div>
|
|
<p class="text-sm text-gray-500">{{ $board->name }}</p>
|
|
<h1 class="text-2xl font-bold text-gray-800 mt-1">
|
|
@if($post->is_notice)
|
|
<span class="inline-flex items-center px-2 py-0.5 rounded text-sm font-medium bg-blue-100 text-blue-800 mr-2">
|
|
공지
|
|
</span>
|
|
@endif
|
|
@if($post->is_secret)
|
|
<svg class="w-5 h-5 inline-block text-gray-400 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"/>
|
|
</svg>
|
|
@endif
|
|
{{ $post->title }}
|
|
</h1>
|
|
</div>
|
|
<a href="{{ route('boards.posts.index', $board) }}" class="text-gray-600 hover:text-gray-900">
|
|
← 목록으로
|
|
</a>
|
|
</div>
|
|
|
|
<!-- 게시글 정보 -->
|
|
<div class="bg-white rounded-lg shadow-sm overflow-hidden">
|
|
<!-- 메타 정보 -->
|
|
<div class="px-6 py-4 border-b border-gray-200 bg-gray-50">
|
|
<div class="flex items-center justify-between text-sm text-gray-500">
|
|
<div class="flex items-center gap-6">
|
|
<span>
|
|
<span class="font-medium text-gray-700">작성자:</span>
|
|
{{ $post->author?->name ?? '알 수 없음' }}
|
|
</span>
|
|
<span>
|
|
<span class="font-medium text-gray-700">작성일:</span>
|
|
{{ $post->created_at->format('Y-m-d H:i') }}
|
|
</span>
|
|
<span>
|
|
<span class="font-medium text-gray-700">조회:</span>
|
|
{{ number_format($post->views) }}
|
|
</span>
|
|
</div>
|
|
@if($post->user_id === auth()->id() || auth()->user()->hasRole(['admin', 'super-admin']))
|
|
<div class="flex items-center gap-2">
|
|
<a href="{{ route('boards.posts.edit', [$board, $post]) }}"
|
|
class="px-3 py-1 text-sm text-blue-600 hover:text-blue-800 border border-blue-300 rounded hover:bg-blue-50 transition">
|
|
수정
|
|
</a>
|
|
<form action="{{ route('boards.posts.destroy', [$board, $post]) }}" method="POST"
|
|
onsubmit="return confirm('정말 삭제하시겠습니까?');">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit"
|
|
class="px-3 py-1 text-sm text-red-600 hover:text-red-800 border border-red-300 rounded hover:bg-red-50 transition">
|
|
삭제
|
|
</button>
|
|
</form>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 커스텀 필드 값 -->
|
|
@if(!empty($customFieldValues))
|
|
<div class="px-6 py-4 border-b border-gray-200 bg-gray-50">
|
|
<div class="grid grid-cols-3 gap-4 text-sm">
|
|
@foreach($board->fields as $field)
|
|
@if(isset($customFieldValues[$field->field_key]))
|
|
<div>
|
|
<span class="font-medium text-gray-700">{{ $field->name }}:</span>
|
|
<span class="text-gray-600 ml-1">{{ $customFieldValues[$field->field_key] }}</span>
|
|
</div>
|
|
@endif
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
@endif
|
|
|
|
<!-- 본문 -->
|
|
<div class="px-6 py-8">
|
|
<div class="prose max-w-none">
|
|
{!! nl2br(e($post->content)) !!}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 첨부파일 -->
|
|
@if($post->files->isNotEmpty())
|
|
<div class="px-6 py-4 border-t border-gray-200 bg-gray-50">
|
|
<h3 class="text-sm font-medium text-gray-700 mb-3">
|
|
첨부파일 ({{ $post->files->count() }}개)
|
|
</h3>
|
|
<div class="space-y-2">
|
|
@foreach($post->files as $file)
|
|
<div class="flex items-center justify-between px-4 py-3 bg-white rounded-lg border border-gray-200">
|
|
<div class="flex items-center gap-3">
|
|
@if($file->isImage())
|
|
<svg class="w-5 h-5 text-green-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"/>
|
|
</svg>
|
|
@else
|
|
<svg class="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
|
|
</svg>
|
|
@endif
|
|
<div>
|
|
<span class="text-sm text-gray-900">{{ $file->display_name ?? $file->original_name }}</span>
|
|
<span class="text-xs text-gray-400 ml-2">({{ $file->getFormattedSize() }})</span>
|
|
</div>
|
|
</div>
|
|
<a href="{{ route('boards.posts.files.download', [$board, $post, $file->id]) }}"
|
|
class="px-3 py-1 text-sm text-blue-600 hover:text-blue-800 border border-blue-300 rounded hover:bg-blue-50 transition">
|
|
다운로드
|
|
</a>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
|
|
<!-- 이전/다음 글 네비게이션 -->
|
|
<div class="mt-6 bg-white rounded-lg shadow-sm overflow-hidden">
|
|
<div class="divide-y divide-gray-200">
|
|
@if($adjacent['prev'])
|
|
<a href="{{ route('boards.posts.show', [$board, $adjacent['prev']->id]) }}"
|
|
class="block px-6 py-4 hover:bg-gray-50 transition">
|
|
<div class="flex items-center">
|
|
<span class="text-sm text-gray-500 w-20">이전글</span>
|
|
<span class="text-gray-900">{{ $adjacent['prev']->title }}</span>
|
|
</div>
|
|
</a>
|
|
@endif
|
|
@if($adjacent['next'])
|
|
<a href="{{ route('boards.posts.show', [$board, $adjacent['next']->id]) }}"
|
|
class="block px-6 py-4 hover:bg-gray-50 transition">
|
|
<div class="flex items-center">
|
|
<span class="text-sm text-gray-500 w-20">다음글</span>
|
|
<span class="text-gray-900">{{ $adjacent['next']->title }}</span>
|
|
</div>
|
|
</a>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 목록 버튼 -->
|
|
<div class="mt-6 flex justify-center">
|
|
<a href="{{ route('boards.posts.index', $board) }}"
|
|
class="px-6 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-lg transition">
|
|
목록
|
|
</a>
|
|
</div>
|
|
|
|
<!-- 알림 메시지 -->
|
|
@if(session('success'))
|
|
<div class="fixed bottom-4 right-4 bg-green-500 text-white px-6 py-3 rounded-lg shadow-lg" id="toast">
|
|
{{ session('success') }}
|
|
</div>
|
|
<script>setTimeout(() => document.getElementById('toast')?.remove(), 3000);</script>
|
|
@endif
|
|
@endsection |