namespace BookStack\Uploads\Controllers;
+use BookStack\Entities\Queries\PageQueries;
use BookStack\Entities\Repos\PageRepo;
use BookStack\Exceptions\FileUploadException;
use BookStack\Exceptions\NotFoundException;
{
public function __construct(
protected AttachmentService $attachmentService,
+ protected PageQueries $pageQueries,
protected PageRepo $pageRepo
) {
}
]);
$pageId = $request->get('uploaded_to');
- $page = $this->pageRepo->getById($pageId);
+ $page = $this->pageQueries->findVisibleByIdOrFail($pageId);
$this->checkPermission('attachment-create-all');
$this->checkOwnablePermission('page-update', $page);
]), 422);
}
- $page = $this->pageRepo->getById($pageId);
+ $page = $this->pageQueries->findVisibleByIdOrFail($pageId);
$this->checkPermission('attachment-create-all');
$this->checkOwnablePermission('page-update', $page);
*/
public function listForPage(int $pageId)
{
- $page = $this->pageRepo->getById($pageId);
+ $page = $this->pageQueries->findVisibleByIdOrFail($pageId);
$this->checkOwnablePermission('page-view', $page);
return view('attachments.manager-list', [
$this->validate($request, [
'order' => ['required', 'array'],
]);
- $page = $this->pageRepo->getById($pageId);
+ $page = $this->pageQueries->findVisibleByIdOrFail($pageId);
$this->checkOwnablePermission('page-update', $page);
$attachmentOrder = $request->get('order');
$attachment = Attachment::query()->findOrFail($attachmentId);
try {
- $page = $this->pageRepo->getById($attachment->uploaded_to);
+ $page = $this->pageQueries->findVisibleByIdOrFail($attachment->uploaded_to);
} catch (NotFoundException $exception) {
throw new NotFoundException(trans('errors.attachment_not_found'));
}