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.

89 lines
2.2 KiB
PHP

<?php
namespace App\Http\Controllers\Front;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\View\View;
use App\Libs\TraitBoard;
use Illuminate\Http\Request;
class IndexController extends Controller
{
use TraitBoard;
protected $page = [
'code' => 'index',
'title' => '',
'subTitle' => '',
'description' => '',
'link' => '/',
'is_main' => true
];
/**
* 홈페이지 메인
*
* @Verb : GET
* @Path : /
* @param Request $request
* @return View
*/
public function index(Request $request)
{
$data = $this->getPostList($request, 'gallery', 2);
logger(json_decode(json_encode($data), true));
logger($data['data']->total());
$pages['total'] = $data['data']->total();
$pages['items'] = $data['data']->perPage() * $data['data']->currentPage();
$pages['mores'] = $data['data']->hasMorePages();
return $this->setView('index', ['list' => $data['data'], 'pages' => $pages]);
}
/**
* 메인 갤러리 목록
*
* @Verb : GET
* @Path : /
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function galleryList(Request $request)
{
$result = $this->getPostList($request, 'gallery', 12);
// logger(json_decode(json_encode($result), true));
$lists = [];
$pages = [];
if (!empty($result['data'])) {
$data = $result['data'];
$lists = $data->toArray();
$pages['total'] = $data->total();
$pages['items'] = $data->perPage() * $data->currentPage();
$pages['mores'] = $data->hasMorePages();
}
return $this->sendJson('데이터 추출 완료', 'success', ['lists' => $lists['data'], 'pages' => $pages]);
}
/**
* 메인 갤러리 상세
*
* @Verb : GET
* @Path : /main/gallery
* @param Request $request
* @return View
*/
public function galleryView(Request $request)
{
$uid = $request->get('uid', '');
$data = $this->showPost($request, 'gallery', $uid);
logger(['uid' => $uid]);
return $this->sendJson('데이터 추출 완료', 'success', $data);
}
}