3 namespace BookStack\References\ModelResolvers;
5 use BookStack\Uploads\Attachment;
7 class AttachmentModelResolver implements CrossLinkModelResolver
9 public function resolve(string $link): ?Attachment
11 $pattern = '/^' . preg_quote(url('/attachments'), '/') . '\/(\d+)/';
13 $match = preg_match($pattern, $link, $matches);
18 $id = intval($matches[1]);
20 return Attachment::query()->find($id);