mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-07-07 16:52:49 +08:00
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:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user