'nullable|exists:tb_board_category,category_id', 'field' => 'nullable|string|in:1,2,3,4,5', 'keyword' => 'nullable|string|max:255', 'page' => 'nullable|numeric', 'perPage' => 'nullable|numeric|in:10,15,20,30,40,50', 'sort' => 'nullable|numeric|in:1,2,3,4' ]; $code = $this->route('code'); $field = $this->query('field'); // 검색구분 $keyword = $this->query('keyword'); // 검색어 $page = $this->query('page', 1); // 페이지 번호 $category = $this->query('category'); // 분류 번호 // 게시글 설정 값 $boardMeta = $this->boardMeta; // PC/MO 구분 한 페이지당 목록 수 if(DEVICE_TYPE_1) { $perPage = ($this->query('per_page') ?? $boardMeta->list_per_page); $pageCount = $boardMeta->list_page_count; }else{ $perPage = ($this->query('per_page') ?? $boardMeta->list_mobile_per_page); $pageCount = $boardMeta->list_page_mobile_count; } $sort = ($this->query('sort') ?? $boardMeta->list_sort_type); // 정렬 (날짜순, 조회순, 댓글순, 추천순) $path = route('board.list', $code); $offset = $this->getPageOffset($page, $perPage); // 페이징 시작 번호 $this->merge([ // 검색 변수 'category' => $category, 'field' => $field, 'keyword' => $keyword, 'page' => intval($page), 'perPage' => intval($perPage), 'pageCount' => intval($pageCount), 'offset' => $offset, 'sort' => intval($sort), 'path' => $path ]); return $rules; } /** * Get custom attributes for validator errors. * * @return array */ public function attributes() { return [ 'category' => '게시판 종류', 'field' => '검색 조건', 'keyword' => '검색어', 'page' => '목록 번호', 'perPage' => '목록 수', 'sort' => '정렬 순서' ]; } /** * Get the error messages for the defined validation rules. * * @return array */ public function messages() { return [ 'category.exists' => '게시판이 존재하지 않습니다.', 'field.in' => '검색 조건이 유효하지 않습니다..', 'keyword.max' => '검색어는 최대 255글자 입력 가능합니다.', 'page.numeric' => '목록 번호가 유효하지 않습니다.', 'perPage.in' => '목록 수가 유효하지 않습니다.', 'sort.in' => '정렬 순서가 유효하지 않습니다.' ]; } }