Skip to content

Commit 49362e3

Browse files
committed
feat(feed): ( #343 ) 动态支持转发功能
1 parent 77be263 commit 49362e3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/slimkit-plus-feed/src/API2/FeedController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,12 @@ protected function saveFeedPaidNode(Request $request, FeedModel $feed)
670670
*/
671671
protected function fillFeedBaseData(Request $request, FeedModel $feed): FeedModel
672672
{
673-
foreach ($request->only(['feed_content', 'feed_from', 'feed_mark', 'feed_latitude', 'feed_longtitude', 'feed_geohash']) as $key => $value) {
673+
$baseFormInputs = $request->only([
674+
'feed_content', 'feed_from', 'feed_mark',
675+
'feed_latitude', 'feed_longtitude', 'feed_geohash',
676+
'repostable_type', 'repostable_id',
677+
]);
678+
foreach (array_filter($baseFormInputs) as $key => $value) {
674679
$feed->$key = $value;
675680
}
676681

packages/slimkit-plus-feed/src/FormRequest/API2/StoreFeedPost.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Illuminate\Validation\Rule;
2424
use Illuminate\Foundation\Http\FormRequest;
2525
use Illuminate\Auth\Access\AuthorizationException;
26+
use Zhiyi\Plus\Types\Models as ModelTypes;
2627

2728
class StoreFeedPost extends FormRequest
2829
{
@@ -82,6 +83,8 @@ public function rules(): array
8283
],
8384
'topics' => ['nullable', 'array'],
8485
'topics.*' => ['required_with:topics', 'integer', 'min:1'],
86+
'repostable_type' => ['required_with:repostable_id', Rule::in(ModelTypes::$types)],
87+
'repostable_id' => ['required_with:repostable_type', 'integer', 'min:1'],
8588
];
8689
}
8790

@@ -120,6 +123,11 @@ public function messages(): array
120123
'topics.*.required_with' => '话题数据不合法',
121124
'topics.*.integer' => '话题数据必须是合法内容',
122125
'topics.*.min' => '话题不存在',
126+
'repostable_type.required_with' => '请求不合法',
127+
'repostable_id.required_with' => '请求不合法',
128+
'repostable_type.in' => '转发的资源类型不合法',
129+
'repostable_id.integer' => '转发的资源 ID 必须是正整数',
130+
'repostable_id.min' => '转发的资源 ID 不合法',
123131
];
124132
}
125133

0 commit comments

Comments
 (0)