feat(content-type): add content_type field, markdown auto-conversion, and API doc updates

- Add content_type column to ul_post via migration
- Install league/commonmark for markdown->HTML conversion
- Add Post model accessors/setters for content_type and content
- Update API Articles controller save/update with content_type support
- Update API docs with content_type parameter and markdown example

Closes content-type-support plan
This commit is contained in:
augushong
2026-04-29 20:46:44 +08:00
parent 0e8944bc7f
commit 6f332467df
5 changed files with 104 additions and 2 deletions

View File

@@ -156,6 +156,30 @@ class Post extends Base
return trim($value);
}
public function getContentTypeAttr($value)
{
return $value ?: 'html';
}
public function setContentTypeAttr($value)
{
if (!in_array($value, ['html', 'markdown'], true)) {
throw new \InvalidArgumentException('Invalid content_type: ' . $value);
}
return $value;
}
public function setContentAttr($value)
{
return trim($value);
}
public function getContentAttr($value)
{
return $value;
}
public function getContentMarkdownAttr()
{
$content_html = $this->getAttr('content_html');