BookStack\Http\Controllers\AttachmentController::update PHP Метод

update() публичный Метод

Update the details of an existing file.
public update ( $attachmentId, Illuminate\Http\Request $request ) : Attachment | mixed
$attachmentId
$request Illuminate\Http\Request
Результат BookStack\Attachment | mixed
    public function update($attachmentId, Request $request)
    {
        $this->validate($request, ['uploaded_to' => 'required|integer|exists:pages,id', 'name' => 'required|string|min:1|max:255', 'link' => 'url|min:1|max:255']);
        $pageId = $request->get('uploaded_to');
        $page = $this->pageRepo->getById($pageId, true);
        $attachment = $this->attachment->findOrFail($attachmentId);
        $this->checkOwnablePermission('page-update', $page);
        $this->checkOwnablePermission('attachment-create', $attachment);
        if (intval($pageId) !== intval($attachment->uploaded_to)) {
            return $this->jsonError('Page mismatch during attachment update');
        }
        $attachment = $this->attachmentService->updateFile($attachment, $request->all());
        return $attachment;
    }