BookStack\Services\AttachmentService::saveNewUpload PHP Method

saveNewUpload() public method

Store a new attachment upon user upload.
public saveNewUpload ( Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile, integer $page_id ) : Attachment
$uploadedFile Symfony\Component\HttpFoundation\File\UploadedFile
$page_id integer
return BookStack\Attachment
    public function saveNewUpload(UploadedFile $uploadedFile, $page_id)
    {
        $attachmentName = $uploadedFile->getClientOriginalName();
        $attachmentPath = $this->putFileInStorage($attachmentName, $uploadedFile);
        $largestExistingOrder = Attachment::where('uploaded_to', '=', $page_id)->max('order');
        $attachment = Attachment::forceCreate(['name' => $attachmentName, 'path' => $attachmentPath, 'extension' => $uploadedFile->getClientOriginalExtension(), 'uploaded_to' => $page_id, 'created_by' => user()->id, 'updated_by' => user()->id, 'order' => $largestExistingOrder + 1]);
        return $attachment;
    }