Skip to content

Commit

Permalink
feat(feed): ( #343 ) 动态支持转发功能
Browse files Browse the repository at this point in the history
  • Loading branch information
medz committed Aug 20, 2018
1 parent 77be263 commit 49362e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/slimkit-plus-feed/src/API2/FeedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,12 @@ protected function saveFeedPaidNode(Request $request, FeedModel $feed)
*/
protected function fillFeedBaseData(Request $request, FeedModel $feed): FeedModel
{
foreach ($request->only(['feed_content', 'feed_from', 'feed_mark', 'feed_latitude', 'feed_longtitude', 'feed_geohash']) as $key => $value) {
$baseFormInputs = $request->only([
'feed_content', 'feed_from', 'feed_mark',
'feed_latitude', 'feed_longtitude', 'feed_geohash',
'repostable_type', 'repostable_id',
]);
foreach (array_filter($baseFormInputs) as $key => $value) {
$feed->$key = $value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Illuminate\Validation\Rule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Auth\Access\AuthorizationException;
use Zhiyi\Plus\Types\Models as ModelTypes;

class StoreFeedPost extends FormRequest
{
Expand Down Expand Up @@ -82,6 +83,8 @@ public function rules(): array
],
'topics' => ['nullable', 'array'],
'topics.*' => ['required_with:topics', 'integer', 'min:1'],
'repostable_type' => ['required_with:repostable_id', Rule::in(ModelTypes::$types)],
'repostable_id' => ['required_with:repostable_type', 'integer', 'min:1'],
];
}

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

Expand Down

0 comments on commit 49362e3

Please sign in to comment.