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.

123 lines
2.8 KiB
PHTML

2 years ago
<?php
namespace App\Http\Controllers\Front;
use App\Http\Controllers\Controller;
use App\Libs\TraitBoard;
use App\Services\CrossFileService;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Illuminate\Contracts\View\View;
class BoardController extends Controller
{
use TraitBoard;
protected $page = [
'code' => 'board',
'title' => '게시판',
'subTitle' => '',
'description' => '',
'link' => '/board/notice'
];
/**
* 게시글 목록
*
* @Verb : GET
* @Path : /board/{code}
* @param Request $request
* @param string $code
* @return View
*/
public function index(Request $request, string $code = '')
{
if ($code == 'inquiry') {
return redirect(route('board.create', [$code]));
}
if ($code == 'news') {
$perPage = 0;
} else {
$perPage = 10;
}
$data = $this->getPostList($request, $code, $perPage);
$this->page['code'] .= '.' . $code;
$this->page['subTitle'] = $data['board']->name;
$skin = $data['board']->skin ?? 'default';
$view = 'board.'. $skin .'.index';
return $this->setView($view, $data);
}
/**
* 게시글 상세
*
* @Verb : GET
* @Path : /board/{code}/{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['subTitle'] = $data->board->name;
$skin = $data->board->skin ?? 'default';
$view = 'board.'. $skin .'.view';
return $this->setView($view, compact('data'));
}
/**
* 문의하기 등록
*
* @Verb : GET
* @Path : /board/{code}/create
* @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['subTitle'] = $data->board->name;
$skin = $data->board->skin ?? 'default';
$view = 'board.'. $skin .'.create';
return $this->setView($view, compact('data'));
}
/**
* 문의하기 저장
*
* @Verb : POST
* @Path : /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']);
}
}