/**
* document manager
*
* @return \Xpressengine\Presenter\RendererInterface
*/
public function docsTrash(Request $request, RouteRepository $routeRepository)
{
$instances = [];
$instanceIds = [];
$urls = [];
$instanceRoutes = $routeRepository->fetchByModule(BoardModule::getId());
foreach ($instanceRoutes as $route) {
$instanceIds[] = $route->instanceId;
$urls[$route->instanceId] = $route->url;
$instances[] = ['id' => $route->instanceId, 'name' => $route->url];
}
$wheres = ['status' => Board::STATUS_TRASH, 'instanceIds' => $instanceIds];
// keyword 검색 처리
if ($request->get('searchKeyword') != '') {
$searchTarget = $request->get('searchTarget');
$searchKeyword = $request->get('searchKeyword');
if ($searchTarget == 'title_content') {
$wheres[$searchTarget] = $searchKeyword;
} else {
$wheres[$searchTarget] = $searchKeyword;
}
}
// 상세 검색 처리
foreach ($request->all() as $key => $value) {
if ($value != '') {
$wheres[$key] = $value;
}
}
$query = Board::whereIn('instanceId', $instanceIds)->where('status', Board::STATUS_TRASH);
$query->orderBy('createdAt', 'desc');
$documents = $query->paginate(15)->appends($request->except('page'));
return $this->presenter->make('docs.trash', compact('documents', 'instances', 'urls'));
}