ensureEnabled(); $data = $request->validate([ 'mobile' => 'required|string|max:20', 'plan4_toman' => 'required|integer|min:0', 'plan12_toman' => 'required|integer|min:0', ]); return response()->json($this->service->setCredit( $data['mobile'], (int) $data['plan4_toman'], (int) $data['plan12_toman'] )); } public function orders() { $this->ensureEnabled(); return response()->json(['data' => $this->service->recentOrders()]); } private function ensureEnabled(): void { if (! $this->service->enabled()) { abort(403, 'خرید اقساطی فعال نیست'); } } }