feat: omit content from report list APIs

This commit is contained in:
kuaifan 2025-12-30 01:58:03 +00:00
parent 8759e6fd7e
commit a336fd4a1a
2 changed files with 14 additions and 2 deletions

View File

@ -51,7 +51,9 @@ class ReportController extends AbstractController
{ {
$user = User::auth(); $user = User::auth();
// //
$builder = Report::with(['receivesUser'])->whereUserid($user->userid); $builder = Report::with(['receivesUser'])
->select(Report::LIST_FIELDS)
->whereUserid($user->userid);
$keys = Request::input('keys'); $keys = Request::input('keys');
if (is_array($keys)) { if (is_array($keys)) {
if ($keys['key']) { if ($keys['key']) {
@ -104,7 +106,8 @@ class ReportController extends AbstractController
public function receive(): array public function receive(): array
{ {
$user = User::auth(); $user = User::auth();
$builder = Report::with(['receivesUser']); $builder = Report::with(['receivesUser'])
->select(Report::LIST_FIELDS);
$builder->whereHas("receivesUser", function ($query) use ($user) { $builder->whereHas("receivesUser", function ($query) use ($user) {
$query->where("report_receives.userid", $user->userid); $query->where("report_receives.userid", $user->userid);
}); });

View File

@ -56,6 +56,15 @@ class Report extends AbstractModel
const WEEKLY = "weekly"; const WEEKLY = "weekly";
const DAILY = "daily"; const DAILY = "daily";
public const LIST_FIELDS = [
'id',
'title',
'type',
'userid',
'sign',
'created_at',
'updated_at',
];
protected $fillable = [ protected $fillable = [
"title", "title",