*/ public function toArray(Request $request): array { $lang = $request->header('Accept-Language') ?? 'ru'; if ($this->problem) { $problem = new ProblemResource($this->problem); } else { $problem = null; } return [ 'id' => $this->id, 'service' => new ServiceResource($this->service), 'power' => $this->power ? [ 'id' => $this->power->id, 'name' => $this->power->name[$lang], 'power' => $this->power->power, ] : null, 'city' => new CityWithRegionResource($this->city), 'comment' => $this->comment, 'phone' => $this->phone, 'full_name' => $this->full_name, 'status' => new StatusResource($this->getStatus), 'problem' => $problem, ]; } }