Skip to content

Commit

Permalink
fix(feed): ( issue zhiyicx/thinksns-plus-android#2209 ) Fixed report …
Browse files Browse the repository at this point in the history
…a feed topic throw SQL reportable not found
  • Loading branch information
medz committed Aug 3, 2018
1 parent 8af36e9 commit 588b264
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions app/API2/Controllers/Feed/TopicReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ public function __invoke(ReportATopicRequest $request, FeedTopicModel $topic): R
$report->reason = $request->input('message');
$report->user_id = $request->user()->id;
$report->target_user = $topic->creator_user_id;
$report->subject = $topic->name;
$report->subject = sprintf('动态话题(%d):%s', $topic->id, $topic->name);
$report->status = 0;

$topic->reports()->save($report);

return (new Response)->setStatusCode(Response::HTTP_NO_CONTENT);
Expand Down
8 changes: 4 additions & 4 deletions app/Models/FeedTopic.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace Zhiyi\Plus\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class FeedTopic extends Model
Expand Down Expand Up @@ -49,10 +49,10 @@ public function users(): BelongsToMany
/**
* The topic reports morph to many.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
*/
public function reports(): MorphToMany
public function reports(): MorphMany
{
return $this->morphToMany(Report::class, 'reportable');
return $this->morphMany(Report::class, 'reportable');
}
}

0 comments on commit 588b264

Please sign in to comment.