- Route Model Binding → 수동 조회로 변경 (board_code + tenant_id) - PostController: resolveBoard() 헬퍼 추가 - t 파라미터 → 시스템 게시판 → 로그인 회원 tenant 순서 - 사이드바 메뉴 리다이렉트: tenant_id ?? 1 fallback 추가 - SidebarMenuService와 동일한 로직으로 일관성 확보 - 게시판 목록 테이블에 게시글 수 컬럼 추가 - 모든 posts View에 tenant_id 파라미터 추가 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
186 lines
8.9 KiB
PHP
186 lines
8.9 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', ['boardCode' => $board->board_code, 't' => $board->tenant_id]) }}" 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', ['boardCode' => $board->board_code, 'post' => $post, 't' => $board->tenant_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>
|
|
<form id="deletePostForm" action="{{ route('boards.posts.destroy', ['boardCode' => $board->board_code, 'post' => $post, 't' => $board->tenant_id]) }}" method="POST">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="button" onclick="confirmDeletePost()"
|
|
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>
|
|
<script>
|
|
function confirmDeletePost() {
|
|
showDeleteConfirm('이 게시글', () => {
|
|
document.getElementById('deletePostForm').submit();
|
|
});
|
|
}
|
|
</script>
|
|
</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
|
|
|
|
<!-- 첨부 이미지 (본문 상단 - 풀 너비) -->
|
|
@php
|
|
$imageFiles = $post->files->filter(fn($file) => $file->isImage());
|
|
$otherFiles = $post->files->filter(fn($file) => !$file->isImage());
|
|
@endphp
|
|
@if($imageFiles->isNotEmpty())
|
|
<div class="px-6 py-4 border-b border-gray-200">
|
|
<div class="space-y-4">
|
|
@foreach($imageFiles as $file)
|
|
<a href="{{ route('boards.posts.files.preview', ['boardCode' => $board->board_code, 'post' => $post, 'fileId' => $file->id, 't' => $board->tenant_id]) }}"
|
|
target="_blank"
|
|
class="block overflow-hidden rounded-lg border border-gray-200 hover:border-blue-400 transition">
|
|
<img src="{{ route('boards.posts.files.preview', ['boardCode' => $board->board_code, 'post' => $post, 'fileId' => $file->id, 't' => $board->tenant_id]) }}"
|
|
alt="{{ $file->display_name ?? $file->original_name }}"
|
|
class="w-full h-auto">
|
|
</a>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
@endif
|
|
|
|
<!-- 본문 -->
|
|
<div class="px-6 py-8">
|
|
<div class="prose max-w-none">
|
|
{!! nl2br(e($post->content)) !!}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 첨부파일 (이미지 제외) -->
|
|
@if($otherFiles->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">
|
|
첨부파일 ({{ $otherFiles->count() }}개)
|
|
</h3>
|
|
<div class="space-y-2">
|
|
@foreach($otherFiles 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">
|
|
<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>
|
|
<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', ['boardCode' => $board->board_code, 'post' => $post, 'fileId' => $file->id, 't' => $board->tenant_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', ['boardCode' => $board->board_code, 'post' => $adjacent['prev']->id, 't' => $board->tenant_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', ['boardCode' => $board->board_code, 'post' => $adjacent['next']->id, 't' => $board->tenant_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', ['boardCode' => $board->board_code, 't' => $board->tenant_id]) }}"
|
|
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 |