imagina / iblog-module
10.0.0
2024-06-11 21:00 UTC
Requires
- php: ^8.1
- cviebrock/eloquent-sluggable: ^8.0|^9.0|^10.0
- imagina/core-module: ^10.0
- imagina/ihelpers-module: ^10.0
Requires (Dev)
- orchestra/testbench: ^8.5
- phpunit/phpunit: ^10
- v10.x-dev
- 10.0.0
- v8.x-dev
- 4.0.x-dev
- dev-master / 4.0.x-dev
- 4.0.27
- 4.0.26
- 4.0.25
- 4.0.24
- 4.0.23
- 4.0.22
- 4.0.21
- 4.0.20
- 4.0.19
- 4.0.18
- 4.0.17
- 4.0.16
- 4.0.15
- 4.0.14
- 4.0.13
- 4.0.12
- 4.0.11
- 4.0.10
- 4.0.9
- 4.0.8
- 4.0.7
- 4.0.6
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.1
- 4.0.0
- 3.1.x-dev
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.x-dev
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.x-dev
- 2.0.0
- dev-dev-tenant
- dev-slim-v8
- dev-dev
- dev-@dev
This package is auto-updated.
Last update: 2024-09-05 16:06:30 UTC
README
博客模块允许授权用户维护博客。博客是一系列带有时戳的帖子,通常按日期查看,就像查看日志一样。博客条目可以是公开的或私有的,具体取决于哪些角色可以访问内容。
安装
composer require imagina/iblog-module
php artisan module:migrate Iblog
端点
路由基础: https://yourhost.com/api/iblog/v1/
-
帖子
-
属性
- 标题: 字符串 (可翻译)
- 描述: 字符串 (可翻译)
- 别名: 字符串 (可翻译)
- 摘要: 字符串 (可翻译)
- meta标题: 字符串 (可翻译)
- meta描述: 字符串 (可翻译)
- meta关键词: 字符串 (可翻译)
- 可翻译选项: 字符串 (可翻译)
- 选项: 字符串
- 分类ID: 字符串
- 分类: 数组
- 标签: 数组
- 用户ID: 字符串
- 状态: 字符串
- 创建时间: 字符串
-
创建
- 方法:
POST
- URI:
/posts
- 方法:
-
读取
- 方法:
GET
- URI:
/posts/:id
- URI:
/posts
- 方法:
-
更新
- 方法:
PUT
- URI:
/post/:id
- 方法:
-
删除
- 方法:
DELETE
- URI:
/posts/:id
- 方法:
-
-
分类
-
属性
- 父ID: 整数
- 选项: 文本
- 标题: 字符串 (可翻译)
- 别名: 字符串 (可翻译)
- 描述: 文本 (可翻译)
- meta标题: 文本 (可翻译)
- meta描述: 文本 (可翻译)
- 可翻译选项: 文本 (可翻译)
-
创建
- 方法:
POST
- URI:
/categories
- 方法:
-
读取
- 方法:
GET
- URI:
/categories/:id
- URI:
/categories
- 方法:
-
更新
- 方法:
PUT
- URI:
/categories/:id
- 方法:
-
删除
- 方法:
DELETE
- URI:
/categories/:id
- 方法:
-
设置关系
由于我们无法直接编辑我们的 Iblog 模块,因为它由 composer 管理,因此我们需要编辑我们的应用程序中 /config/asgard/iblog/
文件夹中的 config.php
文件,以与其他模块建立关系。
导航到名为“动态关系”的部分,默认情况下看起来像这样
'relations' => [
'category'=>[
'store' => function () {
return $this->belongsTo(
\Modules\Marketplace\Entities\Store::class);
},
],
'post'=>[
'store' => function () {
return $this->belongsTo(
\Modules\Marketplace\Entities\Store::class);
},
],
]
现在我们可以使用 $post->store->name
或 $category->store->name
分别访问 iblog 帖子或分类的信息。
在帖子或分类表中添加数据如果您真的需要在分类或帖子表中添加额外的列,例如,如果您想添加一个关系列或额外的查询字段。我们需要编辑我们的应用程序中 /config/asgard/iblog/
文件夹中的 config.php
文件。其中有一个包含对象可填充字段的数组的 fillable 键。
/*
|--------------------------------------------------------------------------
| Fillable user fields
|--------------------------------------------------------------------------
| Set the fillable post and category fields, those fields will be mass assigned
*/
'fillable' => [
'post'=>[
'options',
'category_id',
'user_id',
'status',
'created_at'
],
'category'=>[
'parent_id',
'options'
]
],
将您想要的字段添加到这个数组中。
/*
|--------------------------------------------------------------------------
| Fillable user fields
|--------------------------------------------------------------------------
| Set the fillable post and category fields, those fields will be mass assigned
*/
'fillable' => [
'post'=>[
'options',
'category_id',
'user_id',
'status',
'created_at',
'store_id'
],
'category'=>[
'parent_id',
'options',
'store_id'
]
],