ReportController.php 1.36 KB
<?php

namespace App\Http\Container\AdminSection\Controllers\System;

use App\Helpers\OperationLog;
use App\Models\TidingHasReport;
use Hikoon\LaravelApi\Facades\Response;
use Hikoon\LaravelApi\Support\ApiCode;
use Hikoon\LaravelApi\Support\ApiController;
use Illuminate\Http\Request;

class ReportController extends ApiController
{
    /**
     * @param \Illuminate\Http\Request $request
     * @return \Hikoon\LaravelApi\Facades\Response
     */
    public function index(Request $request): Response
    {
        $pageSize = $request->get('pageSize', 20);
        $filter   = $request->except(['page', 'pageSize']);

        $data = TidingHasReport::filter($filter)->paginate($pageSize);

        return $this->successWithData($data);
    }

    /**
     * @param \Illuminate\Http\Request    $request
     * @param \App\Models\TidingHasReport $report
     * @return \Hikoon\LaravelApi\Facades\Response
     */
    public function update(Request $request, TidingHasReport $report): Response
    {
        $attribute = $request->validate(['status' => 'required|in:0,1'], ['status.required' => '请选择处理状态', 'status.in' => '处理状态不在指定范围内']);
        $report->update($attribute);
        OperationLog::admin()->createAction()->subject($report)->content('处理举报编号:', $report->getKey());
        return $this->success(ApiCode::UPDATE_SUCCESS);
    }
}