user(); $query = Complaint::withoutGlobalScope('store') ->where('customer_id', $customer->id); return $this->paginate( $query->orderByDesc('id')->paginate(10) ); } /** * 提交投诉 */ public function store(Request $request): JsonResponse { /** @var Customer $customer */ $customer = $request->user(); $validated = $request->validate([ 'type' => 'required|integer|in:1,2,3,4', 'content' => 'required|string|max:1000', 'images' => 'nullable|array', 'images.*' => 'nullable|string|max:500', ]); $complaint = Complaint::create([ 'customer_id' => $customer->id, 'store_id' => $customer->store_id, 'type' => (int) $validated['type'], 'content' => $validated['content'], 'images' => $validated['images'] ?? null, 'status' => 1, ]); return $this->success($complaint); } }