You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
200 lines
5.0 KiB
PHP
200 lines
5.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\CrossFileService;
|
|
use App\Libs\TraitBoard;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Contracts\View\View;
|
|
|
|
class BoardController extends Controller
|
|
{
|
|
use TraitBoard;
|
|
|
|
protected $breadcrumbs = [
|
|
['title' => '공지사항', 'link' => '/cms/board/notice']
|
|
];
|
|
|
|
// Page Header
|
|
protected $page = [
|
|
'code' => 'cms.board',
|
|
'title' => '공지사항',
|
|
'icon' => 'fa-book',
|
|
'description' => '',
|
|
'link' => '/cms/board/notice'
|
|
];
|
|
|
|
/**
|
|
* 게시글 목록
|
|
*
|
|
* @Verb : GET
|
|
* @Path : /cms/board/{code}
|
|
* @param Request $request
|
|
* @param string $code
|
|
* @return View
|
|
*/
|
|
public function index(Request $request, string $code = '')
|
|
{
|
|
$perPage = 10;
|
|
|
|
$data = $this->getPostList($request, $code, $perPage);
|
|
|
|
$this->page['code'] .= '.' . $code;
|
|
$this->page['title'] = $data['board']->name;
|
|
$this->page['subTitle'] = $data['board']->name;
|
|
|
|
$view = 'admin.board.index';
|
|
if ($code == 'inquiry') {
|
|
$view = 'admin.board.inquiry.index';
|
|
}
|
|
|
|
return $this->setView($view, $data);
|
|
}
|
|
|
|
/**
|
|
* 게시글 상세
|
|
*
|
|
* @Verb : GET
|
|
* @Path : /cms/board/{code}/view/{uid}
|
|
* @param Request $request
|
|
* @param string $code
|
|
* @param string $uid
|
|
* @return View
|
|
*/
|
|
public function view(Request $request, string $code = '', string $uid = '')
|
|
{
|
|
$data = $this->showPost($request, $code, $uid);
|
|
|
|
$this->page['code'] .= '.' . $code;
|
|
$this->page['title'] = $data['board']->name;
|
|
$this->page['subTitle'] = $data['board']->name . ' 상세';
|
|
|
|
$view = 'admin.board.view';
|
|
if ($code == 'inquiry') {
|
|
$view = 'admin.board.inquiry.view';
|
|
}
|
|
|
|
return $this->setView($view, compact('data'));
|
|
}
|
|
|
|
/**
|
|
* 게시글 등록/수정
|
|
*
|
|
* @Verb : GET
|
|
* @Path : /cms/board/{code}/create
|
|
* @Path : /cms/board/{code}/modify/{uid}
|
|
* @param Request $request
|
|
* @param string $code
|
|
* @param string $uid
|
|
* @return View
|
|
*/
|
|
public function create(Request $request, string $code = '', string $uid = '')
|
|
{
|
|
$data = $this->createPost($request, $code, $uid);
|
|
|
|
$this->page['code'] .= '.' . $code;
|
|
$this->page['title'] = $data->board->name;
|
|
$this->page['subTitle'] = $data->board->name . ($data->mode == 'modify' ? ' 수정' : ' 등록');
|
|
|
|
return $this->setView('admin.board.create', compact('data'));
|
|
}
|
|
|
|
/**
|
|
* 게시글 저장
|
|
*
|
|
* @Verb : POST
|
|
* @Path : /cms/board/store
|
|
* @param Request $request
|
|
* @param CrossFileService $fileService
|
|
* @return JsonResponse
|
|
*/
|
|
public function store(Request $request, CrossFileService $fileService)
|
|
{
|
|
$result = $this->storePost($request, $fileService);
|
|
|
|
return $this->sendJson($result['message'], $result['code']);
|
|
}
|
|
|
|
/**
|
|
* 에디터 이미지 업로드 저장
|
|
*
|
|
* @Verb : POST
|
|
* @Path : /cms/board/image/upload
|
|
* @param Request $request
|
|
* @param CrossFileService $fileService
|
|
* @return JsonResponse
|
|
*/
|
|
public function imageUpload(Request $request, CrossFileService $fileService)
|
|
{
|
|
$result = $this->editorImageUpload($request, $fileService);
|
|
|
|
return $this->sendJson($result['message'], $result['code'], $result['data']);
|
|
}
|
|
|
|
/**
|
|
* 첨부파일 삭제
|
|
*
|
|
* @Verb : POST
|
|
* @Path : /cms/board/asset/delete
|
|
* @param Request $request
|
|
* @param CrossFileService $fileService
|
|
* @return JsonResponse
|
|
*/
|
|
public function assetDelete(Request $request, CrossFileService $fileService)
|
|
{
|
|
$result = $this->assetDelete($request, $fileService);
|
|
|
|
return $this->sendJson($result['message'], $result['code']);
|
|
}
|
|
|
|
/**
|
|
* 댓글 저장
|
|
*
|
|
* @Verb : POST
|
|
* @Path : /cms/board/comment/store
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
*/
|
|
public function commentStore(Request $request)
|
|
{
|
|
$result = $this->storeComment($request);
|
|
|
|
return $this->sendJson($result['message'], $result['code']);
|
|
}
|
|
|
|
/**
|
|
* 댓글 삭제
|
|
*
|
|
* @Verb : POST
|
|
* @Path : /cms/board/comment/delete
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
*/
|
|
public function commentDelete(Request $request)
|
|
{
|
|
$result = $this->deleteComment($request);
|
|
|
|
return $this->sendJson($result['message'], $result['code']);
|
|
}
|
|
|
|
/**
|
|
* 게시글 삭제
|
|
*
|
|
* @Verb : POST
|
|
* @Path : /cms/board/delete
|
|
* @param Request $request
|
|
* @param CrossFileService $fileService
|
|
* @return JsonResponse
|
|
*/
|
|
public function delete(Request $request, CrossFileService $fileService)
|
|
{
|
|
$result = $this->deletePost($request, $fileService);
|
|
|
|
return $this->sendJson($result['message'], $result['code']);
|
|
}
|
|
|
|
}
|